public static void ApplyCategories(this IEnumerable<BaseLibraryLink> links, SearchGroup[] sharedSearchGroups, SearchGroup[] partialSearchGroups = null)
		{
			foreach (var libraryLink in links)
			{
				if (partialSearchGroups == null)
				{
					libraryLink.Tags.Categories.Clear();
					libraryLink.Tags.Categories.AddRange(sharedSearchGroups.Select(searchGroup => searchGroup.Clone()));
				}
				else
				{
					libraryLink.Tags.Categories.RemoveAll(groupForRemove =>
						!sharedSearchGroups.Any(g => g.Equals(groupForRemove)) &&
						!partialSearchGroups.Any(g => g.Equals(groupForRemove)));

					foreach (var searchGroup in libraryLink.Tags.Categories)
					{
						var partialGroup = partialSearchGroups.FirstOrDefault(g => g.Equals(searchGroup));
						var sharedGroup = sharedSearchGroups.FirstOrDefault(g => g.Equals(searchGroup));

						searchGroup.Tags.RemoveAll(tagForRemove =>
							(sharedGroup == null || !sharedGroup.Tags.Any(t => t.Equals(tagForRemove))) &&
							(partialGroup == null || !partialGroup.Tags.Any(t => t.Equals(tagForRemove))));

						if (sharedGroup != null)
							searchGroup.Tags.AddRange(sharedGroup.Tags.Where(tagToAdd => !searchGroup.Tags.Any(t => t.Equals(tagToAdd))));
					}

					libraryLink.Tags.Categories.AddRange(sharedSearchGroups.Where(groupForAdd => !libraryLink.Tags.Categories.Any(g => g.Equals(groupForAdd))));
				}

				libraryLink.MarkAsModified();
			}
		}
Beispiel #2
0
        void Handle_TextChanged(object sender, TextChangedEventArgs e)
        {
            string searchText = "";

            for (int i = 0; i < e.NewTextValue.Length; i++)
            {
                if (i == 0)
                {
                    searchText += (e.NewTextValue[i].ToString()).ToUpper();
                }
                else
                {
                    searchText += (e.NewTextValue[i].ToString()).ToLower();
                }
            }

            ObservableCollection <Search> list = ss.GetSearches(searchText);

            searchGrp = new SearchGroup("Recent Searches");

            foreach (var listItem in list)
            {
                searchGrp.Add(listItem);
            }

            searchElement = new ObservableCollection <SearchGroup>
            {
                searchGrp
            };

            listView.ItemsSource = searchElement;
        }
Beispiel #3
0
        protected void ResetButton_Click(object sender, EventArgs e)
        {
            // RESET THE SESSION
            Session.Remove("ManageUserSearchCriteria");

            // RESET THE FORM
            SearchUserName.Text  = string.Empty;
            SearchEmail.Text     = string.Empty;
            SearchFirstName.Text = string.Empty;
            SearchLastName.Text  = string.Empty;
            SearchCompany.Text   = string.Empty;
            SearchPhone.Text     = string.Empty;

            ListItem item = SearchGroup.Items.FindByValue(_GroupId.ToString());

            if (item != null)
            {
                SearchGroup.ClearSelection();
                item.Selected = true;
            }

            SearchIncludeAnonymous.Checked = false;

            // EXECUTE THE SEARCH AND HIDE THE RESET BUTTON
            SearchButton_Click(sender, e);

            BindSearchPanel();

            // DISPLAY THE RESET BUTTON
            ResetButton.Visible = false;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _EmailListId = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]);
            _EmailList   = EmailListDataSource.Load(_EmailListId);
            if (_EmailList == null)
            {
                Response.Redirect("Default.aspx");
            }
            if (!Page.IsPostBack)
            {
                Caption.Text = string.Format(Caption.Text, _EmailList.Name);
                EmailListUsersCaption.Text = string.Format(EmailListUsersCaption.Text, _EmailList.Name);
                SearchUsersGrid.Visible    = false;
                if (Request.UrlReferrer.AbsolutePath.EndsWith("ManageList.aspx"))
                {
                    FinishLink.NavigateUrl = "ManageList.aspx?EmailListId=" + _EmailListId;
                }
            }

            AlphabetRepeater.DataSource = GetAlphabetDS();
            AlphabetRepeater.DataBind();
            AbleCommerce.Code.PageHelper.SetDefaultButton(SearchEmail, SearchButton.ClientID);
            IList <Group> storeGroups = GroupDataSource.LoadAll();

            SearchGroup.DataSource     = storeGroups;
            SearchGroup.DataTextField  = "Name";
            SearchGroup.DataValueField = "GroupId";
            SearchGroup.DataBind();
        }
Beispiel #5
0
        public SearchResultItem GetSearchResultItem(SearchGroup searchGroup, SearchItem searchResultItem)
        {
            var result = new SearchResultItem
            {
                Name       = searchResultItem.Title,
                Additional = new Dictionary <string, object>
                {
                    {
                        "Type",
                        searchResultItem.EntityType
                    },
                    {
                        "imageRef",
                        WebImageSupplier.GetAbsoluteWebPath(GetImage(searchResultItem.EntityType), ProductEntryPoint.ID)
                    },
                    {
                        "Hint",
                        GetHint(searchResultItem.EntityType)
                    }
                },
                URL = GetItemPath(searchResultItem.EntityType, searchResultItem.ID, searchGroup.ProjectID)
            };

            if (searchResultItem.EntityType != EntityType.Project)
            {
                result.Additional.Add("ProjectName", searchGroup.ProjectTitle);
                result.Date        = searchResultItem.CreateOn;
                result.Description = searchResultItem.Description;
            }

            return(result);
        }
        public ActionResult SearchGroups()
        {
            SearchGroup sgmodel = new SearchGroup();

            TempData["ShowDiv"] = 0;
            return(View(sgmodel));
        }
        public ActionResult DeleteGroup(string university, string department, string term, string course, string id)
        {
            SearchGroup  sgmodel     = new SearchGroup();
            List <Group> tempLst     = new List <Group>();
            int          userid      = Convert.ToInt32(Session["id"]);
            int          grpid       = Convert.ToInt32(id);
            Membership   membermodel = new Membership();

            try
            {
                using (DISCUSSEntities dbcontext = new DISCUSSEntities())
                {
                    var model = dbcontext.Groups.Where(t => t.id == grpid).FirstOrDefault();
                    dbcontext.Groups.Remove(model);
                    var tempList = dbcontext.Memberships.Where(t => t.groupId == grpid).Select(i => i).ToList();
                    dbcontext.Memberships.RemoveRange(tempList);
                    dbcontext.SaveChanges();
                }
            } catch (Exception ex)
            {
                System.Console.Write(ex.StackTrace);
            }

            return(PartialView("_SearchGrid", sgmodel.GrpList));
        }
        void UpdateSearches(string filter = null)
        {
            var search_group = new SearchGroup(SearchService.GetSearches(filter));

            list_view.ItemsSource = new List <SearchGroup> {
                search_group
            };
        }
Beispiel #9
0
 public SearchWrapper(SearchGroup searchGroup)
 {
     if (searchGroup.Items != null)
     {
         Items = searchGroup.Items.Select(x => new SearchItemWrapper(x)).ToArray();
     }
     ProjectOwner = new SimpleProjectWrapper(searchGroup.ProjectID, searchGroup.ProjectTitle);
 }
Beispiel #10
0
            public virtual ICollection <SearchGroup <T> > Merge(IList <IEnumerable <ISearchGroup <T> > > shards, int offset, int topN)
            {
                int maxQueueSize = offset + topN;

                //System.out.println("merge");
                // Init queue:
                for (int shardIDX = 0; shardIDX < shards.Count; shardIDX++)
                {
                    IEnumerable <ISearchGroup <T> > shard = shards[shardIDX];
                    if (shard.Any())
                    {
                        //System.out.println("  insert shard=" + shardIDX);
                        UpdateNextGroup(maxQueueSize, new ShardIter <T>(shard, shardIDX));
                    }
                }

                // Pull merged topN groups:
                List <SearchGroup <T> > newTopGroups = new List <SearchGroup <T> >();

                int count = 0;

                while (queue.Count != 0)
                {
                    MergedGroup <T> group = queue.Min;
                    queue.Remove(group);
                    group.IsProcessed = true;
                    //System.out.println("  pop: shards=" + group.shards + " group=" + (group.groupValue == null ? "null" : (((BytesRef) group.groupValue).utf8ToString())) + " sortValues=" + Arrays.toString(group.topValues));
                    if (count++ >= offset)
                    {
                        SearchGroup <T> newGroup = new SearchGroup <T>();
                        newGroup.GroupValue = group.GroupValue;
                        newGroup.SortValues = group.TopValues;
                        newTopGroups.Add(newGroup);
                        if (newTopGroups.Count == topN)
                        {
                            break;
                        }
                        //} else {
                        // System.out.println("    skip < offset");
                    }

                    // Advance all iters in this group:
                    foreach (ShardIter <T> shardIter in group.Shards)
                    {
                        UpdateNextGroup(maxQueueSize, shardIter);
                    }
                }

                if (newTopGroups.Count == 0)
                {
                    return(null);
                }
                else
                {
                    return(newTopGroups);
                }
            }
		private static IEnumerable<SearchGroup> LoadFromCloudData(IEnumerable<SoapCategory> cloudCategories)
		{
			return cloudCategories.GroupBy(cat => cat.category).Select(group =>
			{
				var searchGroup = new SearchGroup()
				{
					Name = group.Key,
					Description = group.Select(g => g.description).FirstOrDefault()
				};
				searchGroup.Tags.AddRange(group.Select(g => new SearchTag { Name = g.tag }));
				return searchGroup;
			});
		}
        public ActionResult SearchGroups(string university, string department, string term, string course)
        {
            SearchGroup       sgmodel    = new SearchGroup();
            List <Group>      tempList   = new List <Group>();
            List <Membership> memberlist = new List <Membership>();

            sgmodel.University = university;
            sgmodel.Department = department;
            sgmodel.Term       = term;
            sgmodel.Course     = course;
            int id = Convert.ToInt32(Session["id"]);

            try
            {
                using (DISCUSSEntities dbcontext = new DISCUSSEntities())
                {
                    var model = dbcontext.Groups.Where(t => t.university == university &&
                                                       t.department == department &&
                                                       t.term == term && t.courseCode == course).ToList();
                    tempList = model;
                    foreach (var grp in tempList)
                    {
                        var model1 = dbcontext.Memberships.Where(t => t.groupId == grp.id &&
                                                                 t.userId == id).FirstOrDefault();
                        if (model1 != null)
                        {
                            grp.IsMember = true;
                        }
                        else
                        {
                            grp.IsMember = false;
                        }

                        int modelCount = dbcontext.Memberships.Where(t => t.groupId == grp.id).ToList().Count;
                        if (grp.estimateEnrollment.HasValue)
                        {
                            grp.SeatsLeft = (int)grp.estimateEnrollment - modelCount;
                        }

                        var model3 = dbcontext.DiscussUsers.Where(t => t.id == grp.createdBy).Select(i => i.FirstName + " " + i.LastName).FirstOrDefault();
                        grp.Creator = model3;
                    }
                    sgmodel.GrpList = tempList;
                }
            }
            catch (Exception ex)
            { System.Console.Write(ex.StackTrace); }

            TempData["ShowDiv"] = 1;
            return(PartialView("_SearchGrid", sgmodel.GrpList));
        }
Beispiel #13
0
        public List <SearchTreeEntry> CreateSearchTree(SearchWindowContext context)
        {
            var tree = new List <SearchTreeEntry>();

            // First item is the title of the window
            tree.Add(new SearchTreeGroupEntry(new GUIContent("Add Node"), 0));

            // TODO: Custom top level pieces (Comments, new variables, etc)

            // Construct a tree of available nodes by module path
            var nodes = NodeReflection.GetNodeTypes();

            var groups = new SearchGroup(1);

            foreach (var node in nodes.Values)
            {
                var path = node.path;

                // Skip the node if it the module isn't whitelisted
                if (!IsInSupportedModule(path))
                {
                    continue;
                }

                // If we're coming from a port, make sure to only add nodes that accept
                // an input (or output) that's compatible.
                if (connectedPort == null || IsCompatibleWithConnectedPort(node))
                {
                    var group = groups;
                    if (path != null)
                    {
                        for (int i = 0; i < path.Length; i++)
                        {
                            if (!group.subgroups.ContainsKey(path[i]))
                            {
                                group.subgroups.Add(path[i], new SearchGroup(group.depth + 1));
                            }

                            group = group.subgroups[path[i]];
                        }
                    }

                    group.nodes.Add(node);
                }
            }

            groups.AddToTree(tree);

            return(tree);
        }
Beispiel #14
0
 /// <summary>
 /// Searches based upon the given filters
 /// </summary>
 /// <param name="group">The definition to search on</param>
 /// <returns>The result of the search</returns>
 public OperationResultAsLists Search(SearchGroup group)
 {
     try
     {
         return(new OperationResultAsLists(null)
         {
             QuestionnaireUserResponseGroups = this.handler.SearchManager.Search(group)
         });
     }
     catch (Exception ex)
     {
         return(new OperationResultAsLists(ex));
     }
 }
Beispiel #15
0
        private void PopulateView(string filter = null)
        {
            var results = SearchService.GetSearches(filter);

            var recentSearchGroup = new SearchGroup("Recent Searches");

            recentSearchGroup.AddRange(results);

            var searchGroups = new List <SearchGroup>();

            searchGroups.Add(recentSearchGroup);

            listView.ItemsSource = searchGroups;
        }
    void AddGroup(SearchGroup group)
    {
        if (group.children.Count > 0)
        {
            foreach (var child in group.children)
            {
                AddGroup(child);
            }
        }

        foreach (var entry in group.entries)
        {
            k_Entries.Add(entry);
        }
    }
Beispiel #17
0
        public string GetSearchView(SearchGroup searchGroup)
        {
            var page        = new System.Web.UI.Page();
            var oSearchView = (SearchView)LoadControl(PathProvider.GetControlVirtualPath("SearchView.ascx"));

            oSearchView.SearchGroup = searchGroup;
            oSearchView.IsListView  = ProjectID == -1;
            oSearchView.SearchText  = SearchText;

            page.Controls.Add(oSearchView);
            var writer = new System.IO.StringWriter();

            HttpContext.Current.Server.Execute(page, writer, false);
            var output = writer.ToString();

            writer.Close();
            return(output);
        }
Beispiel #18
0
 protected void Page_Init(object sender, EventArgs e)
 {
     AlphabetRepeater.DataSource = GetAlphabetDS();
     AlphabetRepeater.DataBind();
     AbleCommerce.Code.PageHelper.SetDefaultButton(SearchEmail, SearchButton.ClientID);
     SearchGroup.DataSource     = AbleContext.Current.Store.Groups;
     SearchGroup.DataTextField  = "Name";
     SearchGroup.DataValueField = "GroupId";
     SearchGroup.DataBind();
     AddGroup.DataSource = SecurityUtility.GetManagableGroups()
                           .Where(group => group.Name != Group.DefaultUserGroupName);
     AddGroup.DataBind();
     trAddGroup.Visible = AddGroup.Items.Count > 1;
     if (!Page.IsPostBack)
     {
         LoadLastSearch();
     }
 }
Beispiel #19
0
        public SearchGroup ProcessGroup(group g)
        {
            SearchGroup group = new SearchGroup();

            group.IsAndOperator = g.selectedLogicalOperator == "AND";
            foreach (var c in g.children)
            {
                if (c.GetType() == typeof(group))
                {
                    group.Children.Add(this.ProcessGroup((group)c));
                }
                else
                {
                    group.Children.Add(this.ProcessCondition((condition)c));
                }
            }

            return(group);
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _GroupId = AlwaysConvert.ToInt(Request.QueryString["GroupId"]);
            Group group = GroupDataSource.Load(_GroupId);

            if (group == null)
            {
                Response.Redirect("Default.aspx");
            }

            // ensure user has permission to manage this group
            IList <Group> managableGroups = SecurityUtility.GetManagableGroups();

            if (managableGroups.IndexOf(group) < 0)
            {
                Response.Redirect("Default.aspx");
            }

            _IsReadonlyGroup = group.IsReadOnly;
            _Subscriptions   = group.SubscriptionPlans.Count;

            AlphabetRepeater.DataSource = GetAlphabetDS();
            AlphabetRepeater.DataBind();

            if (!Page.IsPostBack)
            {
                SearchGroup.DataSource     = AbleContext.Current.Store.Groups;
                SearchGroup.DataTextField  = "Name";
                SearchGroup.DataValueField = "GroupId";
                SearchGroup.DataBind();

                Caption.Text = string.Format(Caption.Text, group.Name);
                ListItem item = SearchGroup.Items.FindByValue(_GroupId.ToString());
                if (item != null)
                {
                    Session.Remove("ManageUserSearchCriteria");
                    SearchGroup.ClearSelection();
                    item.Selected = true;
                }
                LoadLastSearch();
            }
        }
Beispiel #21
0
        public AirbnbSearchList()
        {
            InitializeComponent();

            ObservableCollection <Search> list = ss.GetSearches();

            searchGrp = new SearchGroup("Recent Searches");

            foreach (var listItem in list)
            {
                searchGrp.Add(listItem);
            }

            searchElement = new ObservableCollection <SearchGroup>
            {
                searchGrp
            };

            listView.ItemsSource = searchElement;
        }
        private void GetCategories(OleDbConnection connection)
        {
            try
            {
                _categories.Clear();
                var dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                foreach (DataRow row in dataTable.Rows)
                {
                    var searchGroup = new SearchGroup();
                    searchGroup.Name = row["TABLE_NAME"].ToString().Replace("$", "").Replace('"'.ToString(), "'").Replace("'", "").Replace("#", ".");

                    if (!searchGroup.Name.Trim().Equals("Categories") &&
                        !searchGroup.Name.Trim().Equals("Settings") &&
                        !searchGroup.Name.Trim().Equals("Groups"))
                    {
                        _categories.Add(searchGroup);
                    }
                }
            }
            catch { }
        }
		private void ApplyData()
		{
			var sharedGroups = _rootNode.Nodes
				.Where(groupNode => groupNode.CheckState == CheckState.Checked)
				.Select(groupNode =>
				{
					var sourceGroup = (SearchGroup)groupNode.Tag;
					var newGroup = new SearchGroup
					{
						Name = sourceGroup.Name,
						Description = sourceGroup.Description
					};
					newGroup.Tags.AddRange(groupNode.Nodes
						.Where(tagNode => tagNode.CheckState == CheckState.Checked)
						.Select(tagNode =>
						{
							var sourceTag = (SearchTag)tagNode.Tag;
							var newTag = new SearchTag { Name = sourceTag.Name };
							return newTag;
						}));
					return newGroup;
				})
				.Where(g => g.Tags.Any())
				.ToArray();

			var partialGroups = _rootNode.Nodes
				.Where(groupNode => groupNode.CheckState != CheckState.Unchecked)
				.Select(groupNode =>
				{
					var sourceGroup = (SearchGroup)groupNode.Tag;
					var newGroup = new SearchGroup
					{
						Name = sourceGroup.Name,
						Description = sourceGroup.Description
					};
					newGroup.Tags.AddRange(groupNode.Nodes
						.Where(tagNode => tagNode.CheckState == CheckState.Indeterminate)
						.Select(tagNode =>
						{
							var sourceTag = (SearchTag)tagNode.Tag;
							var newTag = new SearchTag { Name = sourceTag.Name };
							return newTag;
						}));
					return newGroup;
				})
				.Where(g => g.Tags.Any())
				.ToArray();

			Selection.SelectedObjects.ApplyCategories(sharedGroups, partialGroups);
			EditorChanged?.Invoke(this, new EventArgs());
		}
Beispiel #24
0
        /// <summary>
        /// Builds a response query for a QuestionnaireUserResponseGroup
        /// </summary>
        /// <param name="group">The Search group that contains the search parameters</param>
        /// <returns>The expression that comprises the logic for the query</returns>
        public Expression <Func <QuestionnaireUserResponseGroup, bool> > BuildResponseGroupQuery(SearchGroup group)
        {
            var pr = PredicateBuilder.False <QuestionnaireUserResponseGroup>();

            if (group.IsAndOperator)
            {
                pr = PredicateBuilder.True <QuestionnaireUserResponseGroup>();
            }
            foreach (var child in group.Children)
            {
                if (child == null)
                {
                    continue;
                }
                Expression <Func <QuestionnaireUserResponseGroup, bool> > query = null;
                if (child.GetType() == typeof(SearchGroup))
                {
                    query = this.BuildResponseGroupQuery((SearchGroup)child);
                }
                else
                {
                    query = this.BuildConditionQuery((SearchCondition)child);
                }

                switch (group.IsAndOperator)
                {
                case true:
                    pr = pr.And(query);
                    break;

                case false:
                    pr = pr.Or(query);
                    break;
                }
            }

            return(pr.Expand());
        }
		public override void Load()
		{
			if (!Configuration.RemoteResourceManager.Instance.SDSearchFile.ExistsLocal()) return;
			var document = new XmlDocument();
			document.Load(Configuration.RemoteResourceManager.Instance.SDSearchFile.LocalPath);

			var node = document.SelectSingleNode(@"/SDSearch");
			if (node == null) return;
			foreach (XmlNode childNode in node.ChildNodes)
			{
				switch (childNode.Name)
				{
					case "MaxTags":
						{
							int temp;
							if (Int32.TryParse(childNode.InnerText, out temp))
								MaxTags = temp;
						}
						break;
					case "TagCount":
						{
							bool temp;
							if (Boolean.TryParse(childNode.InnerText, out temp))
								TagCount = temp;
						}
						break;
					case "Category":
						var group = new SearchGroup();
						foreach (XmlAttribute attribute in childNode.Attributes)
						{
							switch (attribute.Name)
							{
								case "Name":
									@group.Name = attribute.Value;
									break;
								case "Description":
									@group.Description = attribute.Value;
									break;
							}
						}
						foreach (XmlNode tagNode in childNode.ChildNodes)
						{
							switch (tagNode.Name)
							{
								case "Tag":
									foreach (XmlAttribute attribute in tagNode.Attributes)
									{
										switch (attribute.Name)
										{
											case "Value":
												if (!String.IsNullOrEmpty(attribute.Value))
													@group.Tags.Add(new SearchTag() { Name = attribute.Value });
												break;
										}
									}
									break;
							}
						}
						if (!String.IsNullOrEmpty(@group.Name) && @group.Tags.Count > 0)
							SearchGroups.Add(@group);
						break;
				}
			}
		}
		private void SaveCategoriesDataSource()
		{
			var commonCategories = _searchGroups
				.Select(sg =>
					{
						var searchGroup = new SearchGroup { Name = sg.DataSource.Name };
						searchGroup.Tags.AddRange(sg.ListBox.Items
							.Where(item => item.CheckState == CheckState.Checked)
							.Select(item =>
							{
								var sourceTag = (SearchTag)item.Value;
								var searchTag = new SearchTag { Name = sourceTag.Name };
								return searchTag;
							}));
						return searchGroup;
					})
				.Where(searchGroup => searchGroup.Tags.Any())
				.ToArray();
			var partialCategories = _searchGroups
				.Select(sg =>
				{
					var searchGroup = new SearchGroup { Name = sg.DataSource.Name };
					searchGroup.Tags.AddRange(sg.ListBox.Items
						.Where(item => item.CheckState == CheckState.Indeterminate)
						.Select(item =>
						{
							var sourceTag = (SearchTag)item.Value;
							var searchTag = new SearchTag { Name = sourceTag.Name };
							return searchTag;
						}));
					return searchGroup;
				})
				.Where(searchGroup => searchGroup.Tags.Any())
				.ToArray();
			_links.ApplyCategories(commonCategories, partialCategories);
		}
Beispiel #27
0
        public void SearchingForCsoport(ActionExecutionContext context)
        {
            var keyArgs = context.EventArgs as KeyEventArgs;

            if (string.IsNullOrEmpty(SearchGroup) || SearchGroup == "Keresés...")
            {
                SearchableCsoportok = new BindableCollection <Osztaly>(Csoportok);

                return;
            }
            if (keyArgs != null)
            {
                SearchableCsoportok = new BindableCollection <Osztaly>();
                foreach (Osztaly item in Csoportok.Where(p => p.Name.ToLower().Contains(SearchGroup.ToLower())).ToArray())
                {
                    SearchableCsoportok.Add(item);
                }
            }
        }
        public ActionResult JoinLeaveGroup(string action, int id)
        {
            SearchGroup  sgmodel     = new SearchGroup();
            List <Group> tempList    = new List <Group>();
            int          userid      = Convert.ToInt32(Session["id"]);
            Membership   membermodel = new Membership();

            try
            {
                using (DISCUSSEntities dbcontext = new DISCUSSEntities())
                {
                    var model = dbcontext.Groups.Where(t => t.id == id).FirstOrDefault();
                    tempList.Add(model);
                }

                foreach (var grp in tempList)
                {
                    if (action == "Join")
                    {
                        using (DISCUSSEntities dbContext = new DISCUSSEntities())
                        {
                            membermodel.groupId = id;
                            membermodel.userId  = userid;
                            dbContext.Memberships.Add(membermodel);
                            dbContext.SaveChanges();
                            grp.IsMember = true;
                            int modelCount = dbContext.Memberships.Where(t => t.groupId == grp.id).ToList().Count;
                            if (grp.estimateEnrollment.HasValue)
                            {
                                grp.SeatsLeft = (int)grp.estimateEnrollment - modelCount;
                            }
                            string name = dbContext.DiscussUsers.Where(t => t.id == grp.createdBy).Select(i => i.FirstName + " " + i.LastName).FirstOrDefault();
                            grp.Creator = name;
                        }
                    }
                    else
                    {
                        using (DISCUSSEntities dbcontext1 = new DISCUSSEntities())
                        {
                            var model = dbcontext1.Memberships.Where(t => t.groupId == id && t.userId == userid).Select(i => i).FirstOrDefault();
                            dbcontext1.Memberships.Remove(model);
                            dbcontext1.SaveChanges();


                            int modelCount = dbcontext1.Memberships.Where(t => t.groupId == grp.id).ToList().Count;
                            if (grp.estimateEnrollment.HasValue)
                            {
                                grp.SeatsLeft = (int)grp.estimateEnrollment - modelCount;
                            }
                            string name = dbcontext1.DiscussUsers.Where(t => t.id == grp.createdBy).Select(i => i.FirstName + " " + i.LastName).FirstOrDefault();
                            grp.Creator = name;
                        }
                    }
                }
                sgmodel.GrpList = tempList;
            }

            catch (Exception ex)
            { System.Console.Write(ex.StackTrace); }

            TempData["ShowDiv"] = 1;
            return(PartialView("_SearchGrid", sgmodel.GrpList));
        }
		public static void ImportLegacyData(this BaseLibraryLink target, Legacy.Entities.LibraryLink legacy)
		{
			target.ExtId = legacy.Identifier;
			target.Name = legacy.Name;
			target.Order = legacy.Order;
			target.AddDate = legacy.AddDate;

			target.Tags.Categories.AddRange(legacy.SearchTags.SearchGroups.Select(legacyGroup =>
			{
				var group = new SearchGroup();
				group.Name = legacyGroup.Name;
				group.Description = legacyGroup.Description;
				group.Tags.AddRange(legacyGroup.Tags.Select(legacyTag => new SearchTag { Name = legacyTag.Name }));
				return group;
			}));
			target.Tags.Keywords.AddRange(legacy.CustomKeywords.Tags.Select(legacyTag => new SearchTag { Name = legacyTag.Name }));
			target.Tags.SuperFilters.AddRange(legacy.SuperFilters.Select(superFilter => superFilter.Name));

			target.Widget.WidgetType = legacy.EnableWidget ? WidgetType.CustomWidget : target.Widget.DefaultWidgetType;
			target.Widget.Image = (Image)(legacy.Widget != null ? legacy.Widget.Clone() : null);

			if (legacy.BannerProperties != null)
			{
				target.Banner.Enable = legacy.BannerProperties.Enable;
				if (target.Banner.Enable)
				{
					target.Banner.Image = (Image)(legacy.BannerProperties.Image != null ? legacy.BannerProperties.Image.Clone() : null);
					target.Banner.ImageAlignement = (HorizontalAlignment)(Int32)legacy.BannerProperties.ImageAlignement;
					target.Banner.TextMode = legacy.BannerProperties.ShowText ? BannerTextMode.CustomText : BannerTextMode.NoText;
					if (target.Banner.TextMode == BannerTextMode.CustomText)
					{
						target.Banner.Font = (Font)legacy.BannerProperties.Font.Clone();
						target.Banner.ForeColor = legacy.BannerProperties.ForeColor;
						target.Banner.Text = legacy.BannerProperties.Text;
					}
				}
			}

			target.Security.AssignedUsers = legacy.ExtendedProperties.AssignedUsers;
			target.Security.DeniedUsers = legacy.ExtendedProperties.DeniedUsers;
			target.Security.IsForbidden = legacy.ExtendedProperties.IsForbidden;
			target.Security.IsRestricted = legacy.ExtendedProperties.IsRestricted;
			target.Security.NoShare = legacy.ExtendedProperties.NoShare;

			if (target is LineBreak && legacy.LineBreakProperties != null)
			{
				target.Settings.Note = legacy.LineBreakProperties.Note;
				if (legacy.ExtendedProperties.Font != null)
					target.Settings.Font = (Font)legacy.LineBreakProperties.Font.Clone();
				target.Settings.ForeColor = legacy.LineBreakProperties.ForeColor;
			}
			if (target is LibraryObjectLink)
			{
				((LibraryObjectLink)target).RelativePath = legacy.RelativePath.StartsWith(Path.DirectorySeparatorChar.ToString()) ? legacy.RelativePath.Substring(1) : legacy.RelativePath;
				target.Settings.Note = !String.IsNullOrEmpty(legacy.ExtendedProperties.Note) ? legacy.ExtendedProperties.Note.Replace("-", String.Empty).Trim() : String.Empty;
				if (legacy.ExtendedProperties.Font != null)
					target.Settings.Font = (Font)legacy.ExtendedProperties.Font.Clone();
				if (legacy.ExtendedProperties.IsSpecialFormat)
					target.Settings.ForeColor = legacy.ExtendedProperties.ForeColor;
				((LibraryObjectLinkSettings)target.Settings).HoverNote = legacy.ExtendedProperties.HoverNote;
				if (legacy.ExtendedProperties.IsBold)
					((LibraryObjectLinkSettings)target.Settings).RegularFontStyle = FontStyle.Bold;
				((LibraryObjectLinkSettings)target.Settings).IsSpecialFormat = legacy.ExtendedProperties.IsSpecialFormat;
				((LibraryObjectLink)target).ExpirationSettings.Enable = legacy.ExpirationDateOptions.EnableExpirationDate;
				((LibraryObjectLink)target).ExpirationSettings.ExpirationDate = legacy.ExpirationDateOptions.ExpirationDate;
				((LibraryObjectLink)target).ExpirationSettings.MarkWhenExpired = legacy.ExpirationDateOptions.LabelLinkWhenExpired;
				((LibraryObjectLink)target).ExpirationSettings.SendEmailOnSync = legacy.ExpirationDateOptions.SendEmailWhenSync;
			}
			if (target is WebLink)
			{
				((WebLinkSettings)target.Settings).ForcePreview = legacy.ExtendedProperties.ForcePreview;
			}
			if (target is LibraryFileLink)
			{
				((LibraryFileLink)target).DataSourceId = !legacy.RootId.Equals(Guid.Empty) ? legacy.RootId : target.ParentLibrary.DataSourceId;
				((LibraryFileLink)target).IsDead = legacy.IsDead;
			}
			if (target is DocumentLink)
			{
				((DocumentLinkSettings)target.Settings).GenerateContentText = legacy.ExtendedProperties.GenerateContentText;
				((DocumentLinkSettings)target.Settings).GeneratePreviewImages = legacy.ExtendedProperties.GeneratePreviewImages;
			}
			if (target is ExcelLink)
			{
				((ExcelLinkSettings)target.Settings).GenerateContentText = legacy.ExtendedProperties.GenerateContentText;
			}
			if (target is VideoLink)
			{
				((VideoLinkSettings)target.Settings).ForcePreview = legacy.ExtendedProperties.ForcePreview;
			}
			if (target is PowerPointLink && legacy.PresentationProperties != null)
			{
				if (legacy.PreviewContainer != null)
					((PowerPointLinkSettings)target.Settings).Id = Guid.Parse(legacy.PreviewContainer.Identifier);
				((PowerPointLinkSettings)target.Settings).Width = legacy.PresentationProperties.Width;
				((PowerPointLinkSettings)target.Settings).Height = legacy.PresentationProperties.Height;
			}
			if (target is LibraryFolderLink && legacy is Legacy.Entities.LibraryFolderLink)
			{
				foreach (var legacyLink in ((Legacy.Entities.LibraryFolderLink)legacy).FolderContent)
				{
					LibraryFileLink libraryLink;
					switch (legacyLink.Type)
					{
						case Legacy.Entities.FileTypes.Folder:
							libraryLink = WallbinEntity.CreateEntity<LibraryFolderLink>();
							break;
						default:
							libraryLink = LibraryFileLink.Create(legacyLink.OriginalPath);
							break;
					}
					libraryLink.FolderLink = ((LibraryFolderLink)target);
					libraryLink.ImportLegacyData(legacyLink);
					((LibraryFolderLink)target).Links.Add(libraryLink);
				}
			}
		}
		public SearchGroupContainer(SearchGroup dataSource)
		{
			DataSource = dataSource;
			Init();
		}
        private void Show()
        {
            UpdateBounds();
            if (listData.Count <= 0)
            {
                return;
            }
            searchList.Add(SearchGroup.Get(0, listData.Count - 1, this));
            bool found          = false;
            int  foundIndex     = -1;
            uint maxSearchTimes = 1000;

            while (searchList.Count > 0 && (--maxSearchTimes > 0))
            {
                var curSearch = searchList[0];
                searchList.RemoveAt(0);
                ObjectPool <SearchGroup> .Release(curSearch);

                if (curSearch.found)
                {
                    found      = true;
                    foundIndex = curSearch.middle;
                    break;
                }
                else
                {
                    curSearch.Expand(searchList, this);
                }
                SearchListSort();
            }
            //Debug.LogWarning("seachTimes:" + (1000 - maxSearchTimes));
            if (maxSearchTimes == 0)
            {
                Debug.LogWarning("maxSearchTimes == 0");
            }
            if (searchList.Count > 0)
            {
                foreach (var aSearch in searchList)
                {
                    ObjectPool <SearchGroup> .Release(aSearch);
                }
                searchList.Clear();
            }
            //上下寻找下一帧视野内的所有ScrollData
            if (found)
            {
                var nextVisibleDatas = ListPool <ScrollData> .Get();

                nextVisibleDatas.Add(listData[foundIndex]);
                float lastLineStartPos = GetScrollDataLineStartPos(listData[foundIndex]);
                //向上
                for (int i = foundIndex - 1; i >= 0; i--)
                {
                    var curData         = listData[i];
                    var curLineStartPos = GetScrollDataLineStartPos(curData);
                    if (lastLineStartPos != curLineStartPos)
                    {
                        if (found)
                        {
                            if (curData.IsVisible())
                            {
                                nextVisibleDatas.Add(curData);
                            }
                            found            = curData.isVisible;
                            lastLineStartPos = curLineStartPos;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (curData.IsVisible())
                        {
                            nextVisibleDatas.Add(curData);
                            found = true;
                        }
                    }
                }
                //向下
                lastLineStartPos = GetScrollDataLineStartPos(listData[foundIndex]);
                found            = true;
                for (int i = foundIndex + 1; i < listData.Count; i++)
                {
                    var curData         = listData[i];
                    var curLineStartPos = GetScrollDataLineStartPos(curData);
                    if (lastLineStartPos != curLineStartPos)
                    {
                        if (found)
                        {
                            if (curData.IsVisible())
                            {
                                nextVisibleDatas.Add(curData);
                            }
                            found            = curData.isVisible;
                            lastLineStartPos = curLineStartPos;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (curData.IsVisible())
                        {
                            nextVisibleDatas.Add(curData);
                            found = true;
                        }
                    }
                }

                //下次不再显示的Data隐藏
                foreach (var aData in nextVisibleDatas)
                {
                    this.listVisibleScrollData.Remove(aData);
                }
                foreach (var tempData in listVisibleScrollData)
                {
                    tempData.Hide();
                }
                //设置当前显示的Data
                this.listVisibleScrollData.Clear();
                this.listVisibleScrollData.AddRange(nextVisibleDatas);
                ListPool <ScrollData> .Release(nextVisibleDatas);

                foreach (var visibleData in this.listVisibleScrollData)
                {
                    visibleData.Show(dataChange);
                }
            }
        }
Beispiel #32
0
        /// <summary>
        /// Start
        /// </summary>
        void Start()
        {
            // よく使用するため、コントローラの参照をあらかじめ取得しておく
            _nazotokiAdvEngineController = UtageUtil.GetNazotokiAdvEngineController();
            _searchController            = SearchGroup.GetComponent <SearchController>();
            _mapController  = _mapGroup.GetComponent <MapController>();
            _quizController = _quizGroup.GetComponent <QuizController>();

            // 初期化
            _currentGetItemList = new List <string>();
            _completeHouseCount = 1;

            // TODO: 外部ファイルから読み込み
            _itemInfoList  = new List <ItemInfo>();
            _quizInfoList  = new List <QuizInfo>();
            _stageInfoList = new List <StageInfo>();
            _houseInfoList = new List <HouseInfo>();

            // アイテム情報を読み込む
            var item1 = new ItemInfo();

            item1.Id          = "item_sample_1";
            item1.Type        = ItemType.Equipment;
            item1.Name        = "ほげ";
            item1.Description = "アイテム説明1";
            item1.ThmFilePath = "Utage/Dialog/Inventory/ItemThumbnail/thm_sample_001";
            item1.OrgFilePath = "Utage/Dialog/ItemDetail/ItemOrg/org_sample_001";
            item1.SpThm       = Resources.Load <Sprite>(item1.ThmFilePath);
            item1.SpOrg       = Resources.Load <Sprite>(item1.OrgFilePath);
            ItemInfoList.Add(item1);

            var item2 = new ItemInfo();

            item2.Id          = "item_sample_2";
            item2.Type        = ItemType.Equipment;
            item2.Name        = "ふが";
            item2.Description = "アイテム説明2";
            item2.ThmFilePath = "Utage/Dialog/Inventory/ItemThumbnail/thm_sample_002";
            item2.OrgFilePath = "Utage/Dialog/ItemDetail/ItemOrg/org_sample_002";
            item2.SpThm       = Resources.Load <Sprite>(item2.ThmFilePath);
            item2.SpOrg       = Resources.Load <Sprite>(item2.OrgFilePath);
            ItemInfoList.Add(item2);

            var item3 = new ItemInfo();

            item3.Id          = "item_sample_3";
            item3.Type        = ItemType.UseRooms;
            item3.Name        = "ハゲ";
            item3.Description = "アイテム説明3";
            item3.ThmFilePath = "Utage/Dialog/Inventory/ItemThumbnail/thm_sample_003";
            item3.OrgFilePath = "Utage/Dialog/ItemDetail/ItemOrg/org_sample_003";
            item3.SpThm       = Resources.Load <Sprite>(item3.ThmFilePath);
            item3.SpOrg       = Resources.Load <Sprite>(item3.OrgFilePath);
            ItemInfoList.Add(item3);

            var item4 = new ItemInfo();

            item4.Id          = "item_sample_4";
            item4.Type        = ItemType.UseBossRoom;
            item4.Name        = "手紙";
            item4.Description = "直接届けられない想いを伝えるために……";
            item4.ThmFilePath = "Utage/Dialog/Inventory/ItemThumbnail/thm_sample_004";
            item4.OrgFilePath = "Utage/Dialog/ItemDetail/ItemOrg/org_sample_004";
            item4.SpThm       = Resources.Load <Sprite>(item4.ThmFilePath);
            item4.SpOrg       = Resources.Load <Sprite>(item4.OrgFilePath);
            ItemInfoList.Add(item4);

            CurrentGetItemList.Add(item1.Id);
            CurrentGetItemList.Add(item2.Id);

            var quizInfo1 = new QuizInfo()
            {
                Id                     = "quiz_sample_1",
                CorrectAnswer          = "興味",
                GetItemId              = "item_sample_4",
                BeforeScenarioLabel    = "Test1",
                EndScenarioLabel       = "Test2",
                HintScenarioLabelList  = new List <string>(),
                QuestionObjectFilePath = "Game/Prefab/Quiz/Question/SampleQuestion"
            };

            _quizInfoList.Add(quizInfo1);

            var quizInfo2 = new QuizInfo()
            {
                Id                     = "quiz_sample_2",
                CorrectAnswer          = "兵",
                GetItemId              = "item_sample_4",
                BeforeScenarioLabel    = "Test3",
                EndScenarioLabel       = "Test4",
                HintScenarioLabelList  = new List <string>(),
                QuestionObjectFilePath = "Game/Prefab/Quiz/Question/Sample2Question"
            };

            _quizInfoList.Add(quizInfo2);

            var houseInfo1 = new HouseInfo()
            {
                Id = "house_sample_1",
                BeforeScenarioLabel = "Test1",
                EndScenarioLabel    = "Test2",
                QuizId = "quiz_sample_1",
                HouseObjectFilePath = "Game/Prefab/Search/House/SampleHouse"
            };

            _houseInfoList.Add(houseInfo1);

            var houseInfo2 = new HouseInfo()
            {
                Id = "house_sample_2",
                BeforeScenarioLabel = "Test4",
                EndScenarioLabel    = "Test3",
                QuizId = "quiz_sample_2",
                HouseObjectFilePath = "Game/Prefab/Search/House/Sample2House"
            };

            _houseInfoList.Add(houseInfo2);

            var stageInfo1 = new StageInfo()
            {
                Id = "stage_sample_1",
                StageObjectFilePath   = "Game/Prefab/Map/Stage/SampleStage",
                EpilogueScenarioLabel = "Test1",
                PrologueScenarioLabel = "プロローグ"
            };

            _stageInfoList.Add(stageInfo1);
            _currentStageInfo = stageInfo1;

            // 最初はシナリオシーン
            _currentScenarioLabel = stageInfo1.PrologueScenarioLabel;
            ChangeGameMode(GameMode.Senario);
        }
Beispiel #33
0
        /// <summary>
        /// Searchers the QuestionnaireUserGroups with the given parameters
        /// </summary>
        /// <param name="group">The root of the search parameters</param>
        /// <returns>A list of all the QuestionnaireUserResponseGroups that match the search parameters</returns>
        public List <QuestionnaireUserResponseGroup> SearchQuestionnaireUserResponseGroups(SearchGroup group)
        {
            var pr = this.BuildResponseGroupQuery(group);

            pr = pr.And(r => this.context.Questionnaires.OfType <ProInstrument>().Select(q => q.Id).Contains(r.Questionnaire.Id));

            var query = this.context.QuestionnaireUserResponseGroups.Include(r => r.Questionnaire).Include(r => r.Responses.Select(resp => resp.Item.OptionGroups)).Include(r => r.Responses.Select(resp => resp.Option.Group.Item)).Include(r => r.Patient).Include(r => r.ProDomainResultSet.Select(s => s.Results.Select(sr => sr.Domain.ResultRanges))).AsExpandable();

            query = query.Where(r => r.Completed).Where(pr.Expand());

            var result = query.ToList();

            return(result);
        }
        public void Convert(IList <string> destinationFolderPaths)
        {
            var searchGroups        = new List <SearchGroup>();
            var searchTopGroupIcons = new Dictionary <string, string>();
            var maxTags             = 0;
            var tagCount            = false;

            var connnectionString =
                String.Format(
                    @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"";",
                    _sourceFilePath);

            using (var connection = new OleDbConnection(connnectionString))
            {
                try
                {
                    connection.Open();
                }
                catch (Exception)
                {
                    throw new ConversionException {
                              SourceFilePath = _sourceFilePath
                    };
                }
                if (connection.State == ConnectionState.Open)
                {
                    //Load Settings
                    {
                        var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Settings$]", connection);
                        var dataTable   = new DataTable();
                        try
                        {
                            dataAdapter.Fill(dataTable);
                            foreach (DataRow row in dataTable.Rows)
                            {
                                if (row[0].ToString().Equals("Max Tags") && int.TryParse(row[1].ToString(), out int tempInt))
                                {
                                    maxTags = tempInt;
                                }
                                else
                                {
                                    if (row[0].ToString().Equals("Tag Count") && bool.TryParse(row[1].ToString(), out bool tempBool))
                                    {
                                        tagCount = tempBool;
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            dataAdapter.Dispose();
                            dataTable.Dispose();
                        }
                    }

                    //Load Top Group Icons
                    {
                        var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Groups$]", connection);
                        var dataTable   = new DataTable();
                        try
                        {
                            dataAdapter.Fill(dataTable);
                            foreach (DataRow row in dataTable.Rows)
                            {
                                var topGroupName = row[0].ToString().Trim();
                                var topGroupIcon = row[1].ToString().Trim();
                                searchTopGroupIcons.Add(topGroupName, topGroupIcon);
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            dataAdapter.Dispose();
                            dataTable.Dispose();
                        }
                    }

                    //Load Groups
                    {
                        GetCategories(connection);
                        var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Categories$]", connection);
                        var dataTable   = new DataTable();
                        try
                        {
                            dataAdapter.Fill(dataTable);
                            if (dataTable.Rows.Count > 1 && dataTable.Columns.Count > 1)
                            {
                                foreach (DataRow row in dataTable.Rows)
                                {
                                    string      groupName   = row[0].ToString().Trim();
                                    SearchGroup searchGroup = _categories.FirstOrDefault(x => x.Name.Equals(groupName));
                                    if (searchGroup != null)
                                    {
                                        searchGroup.Description = row[1].ToString().Trim();

                                        var topGroupName = row[2].ToString().Trim();
                                        searchGroup.TopGroupName = topGroupName;
                                        if (searchTopGroupIcons.ContainsKey(topGroupName))
                                        {
                                            searchGroup.TopGroupIcon = searchTopGroupIcons[topGroupName];
                                        }

                                        searchGroups.Add(searchGroup);
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            dataAdapter.Dispose();
                            dataTable.Dispose();
                        }
                    }

                    //Load Tags
                    foreach (SearchGroup searchGroup in searchGroups)
                    {
                        searchGroup.Tags.Clear();
                        var dataAdapter = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}$]", searchGroup.Name.Replace(".", "#")),
                                                               connection);
                        var dataTable = new DataTable();
                        try
                        {
                            dataAdapter.Fill(dataTable);
                            if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0)
                            {
                                foreach (DataRow row in dataTable.Rows)
                                {
                                    string value = row[0].ToString().Trim();
                                    if (!string.IsNullOrEmpty(value))
                                    {
                                        searchGroup.Tags.Add(value);
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            dataAdapter.Dispose();
                            dataTable.Dispose();
                        }
                    }
                }
                else
                {
                    throw new ConversionException {
                              SourceFilePath = _sourceFilePath
                    }
                };
                connection.Close();
            }

            var xml = new StringBuilder();

            xml.AppendLine("<SDSearch>");
            xml.AppendLine("<MaxTags>" + maxTags + "</MaxTags>");
            xml.AppendLine("<TagCount>" + tagCount + "</TagCount>");
            foreach (SearchGroup group in searchGroups)
            {
                xml.Append(@"<Category ");
                xml.Append("Name = \"" + group.Name.Replace(@"&", "&#38;").Replace(@"<", "&#60;").Replace("\"", "&quot;") + "\" ");
                xml.Append("Description = \"" + group.Description.Replace(@"&", "&#38;").Replace(@"<", "&#60;").Replace("\"", "&quot;") + "\" ");
                xml.Append("Group = \"" + group.TopGroupName.Replace(@"&", "&#38;").Replace(@"<", "&#60;").Replace("\"", "&quot;") + "\" ");
                xml.Append("GroupIcon = \"" + group.TopGroupIcon.Replace(@"&", "&#38;").Replace(@"<", "&#60;").Replace("\"", "&quot;") + "\" ");
                xml.AppendLine(@">");
                foreach (string tag in group.Tags)
                {
                    xml.Append(@"<Tag ");
                    xml.Append("Value = \"" + tag.Replace(@"&", "&#38;").Replace(@"<", "&#60;").Replace("\"", "&quot;") + "\" ");
                    xml.AppendLine(@"/>");
                }
                xml.AppendLine(@"</Category>");
            }
            xml.AppendLine(@"</SDSearch>");

            foreach (var folderPath in destinationFolderPaths)
            {
                var xmlPath = Path.Combine(folderPath, DestinationFileName);
                using (var sw = new StreamWriter(xmlPath, false))
                {
                    sw.Write(xml.ToString());
                    sw.Flush();
                }
            }
        }
Beispiel #35
0
 /// <summary>
 /// Searches based upon the given filters
 /// </summary>
 /// <param name="group">The definition to search on</param>
 /// <returns>The result of the search</returns>
 public OperationResultAsLists Search(SearchGroup group)
 {
     return(this.Channel.Search(group));
 }
Beispiel #36
0
        public async Task <ActionResult> GetGroupInfo(SearchGroup searchGroup)
        {
            int    groupId = -1;
            int    userId  = -1;
            string status  = null;

            //1.確認token
            using (SqlConnection sqlConnection = new SqlConnection(Global.connect_string + " ;MultipleActiveResultSets = true"))
            {
                sqlConnection.Open();
                string strCheckToken = "SELECT [UserId] FROM [UserInfo] WHERE [Token]=@Token AND [Email]=@ACCOUNT";
                using (SqlCommand cmdReadUserId = new SqlCommand(strCheckToken, sqlConnection))
                {
                    cmdReadUserId.Parameters.AddWithValue("@Token", searchGroup.Token);
                    string[] account = searchGroup.Token.Split("/");
                    cmdReadUserId.Parameters.AddWithValue("@ACCOUNT", account[0]);
                    using (SqlDataReader readUserId = cmdReadUserId.ExecuteReader())
                    {
                        if (readUserId.HasRows)
                        {
                            if (readUserId.Read())
                            {
                                userId = (int)readUserId[0];
                            }
                        }
                    }
                }
                if (userId == -1)
                {
                    return(CreatedAtAction("GetGroupInfo", new { errorcode = -401, msg = "can't find user" }));
                }
                if (searchGroup.GroupName == null)
                {//2.傳入的是invitedcode
                    Console.WriteLine("search group by invited code");
                    ReturnSearchGroup resultGroup = new ReturnSearchGroup();
                    string            strGetGroup = "SELECT GroupId,GroupName,GroupIntro,[GroupPhoto] FROM [GroupInfo] WHERE [InvitedCode]=@invitedCode";
                    using (SqlCommand cmd = new SqlCommand(strGetGroup, sqlConnection))
                    {
                        cmd.Parameters.AddWithValue("@invitedCode", searchGroup.InvitedCode);
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows && reader.Read())
                        {
                            groupId                = reader.GetInt32(0);
                            resultGroup.GroupId    = groupId;
                            resultGroup.GroupName  = reader.GetString(1);
                            resultGroup.GroupIntro = reader.GetString(2);
                            string photoRoute = null;
                            if (!reader.IsDBNull(3))
                            {
                                photoRoute = Global.group_photo_url + reader.GetString(3);
                            }
                            resultGroup.GroupPhoto = photoRoute;
                            //確認身分
                            string strIsMember = "SELECT Accepted FROM [Group_User] WHERE [GroupId]=@groupId AND [UserId]=@userId";
                            using (SqlCommand cmdMatch = new SqlCommand(strIsMember, sqlConnection))
                            {
                                cmdMatch.Parameters.AddWithValue("@groupId", groupId);
                                cmdMatch.Parameters.AddWithValue("@userId", userId);
                                using (SqlDataReader readMatch = cmdMatch.ExecuteReader())
                                {
                                    if (readMatch.HasRows && readMatch.Read())
                                    {
                                        if (readMatch.GetInt32(0) == 0 || readMatch.GetInt32(0) == 3)
                                        {
                                            status = "alreadySend";
                                        }
                                        else
                                        {
                                            status = "isMember";
                                        }
                                    }
                                }
                            }
                            if (status == null)
                            {
                                status = "canApply";
                            }
                            resultGroup.Status = status;
                            return(CreatedAtAction("GetGroupInfo", new { errorcode = -1, msg = "success get group", Group = resultGroup }));
                        }
                        return(CreatedAtAction("GetGroupInfo", new { errorcode = -402, msg = "can't find group" }));
                    }
                }
                else //3.傳入的是名字
                {
                    Console.WriteLine("search group by name");
                    List <ReturnSearchGroup> resultGroup = new List <ReturnSearchGroup>();
                    string strGetGroup = @"DECLARE @Search NVARCHAR(20)
                                            SET @Search = @groupName
                                            SELECT GroupId,GroupName, GroupIntro,GroupPhoto
                                                FROM[GroupInfo]
                                                WHERE[GroupName] LIKE '%' + @Search + '%'";
                    using (SqlCommand cmd = new SqlCommand(strGetGroup, sqlConnection))
                    {
                        cmd.Parameters.AddWithValue("@groupName", searchGroup.GroupName);
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ReturnSearchGroup newObj = new ReturnSearchGroup();
                                groupId           = reader.GetInt32(0);
                                newObj.GroupId    = groupId;
                                newObj.GroupName  = reader.GetString(1);
                                newObj.GroupIntro = reader.GetString(2); //確認身分
                                string photoRoute = null;
                                if (!reader.IsDBNull(3))
                                {
                                    photoRoute = Global.group_photo_url + reader.GetString(3);
                                }
                                newObj.GroupPhoto = photoRoute;

                                string strIsMember = "SELECT Accepted FROM [Group_User] WHERE [GroupId]=@groupId AND [UserId]=@userId";
                                using (SqlCommand cmdMatch = new SqlCommand(strIsMember, sqlConnection))
                                {
                                    cmdMatch.Parameters.AddWithValue("@groupId", groupId);
                                    cmdMatch.Parameters.AddWithValue("@userId", userId);
                                    using (SqlDataReader readerMember = cmdMatch.ExecuteReader())
                                    {
                                        if (readerMember.HasRows && readerMember.Read())
                                        {
                                            if (readerMember.GetInt32(0) == 0 || readerMember.GetInt32(0) == 3)
                                            {
                                                status = "alreadySend";
                                            }
                                            else
                                            {
                                                status = "isMember";
                                            }
                                        }
                                    }
                                }
                                if (status == null)
                                {
                                    status = "canApply";
                                }
                                newObj.Status = status;
                                resultGroup.Add(newObj);
                                status = null;
                            }
                            reader.Close();
                            return(CreatedAtAction("GetGroupInfo", new { errorcode = -1, msg = "success get group", Group = resultGroup }));
                        }
                        return(CreatedAtAction("GetGroupInfo", new { errorcode = -402, msg = "can't find group" }));
                    }
                }
            }

            //var groupInfo = await _context.GroupInfo.FindAsync(id);

            //if (groupInfo == null)
            //{
            //    return NotFound();
            //}

            //return groupInfo;
        }
		public static IList<SearchGroup> GetCommonCategories(this IList<BaseLibraryLink> links)
		{
			var commonCategories = new List<SearchGroup>();
			var allCategories = links.SelectMany(l => l.Tags.Categories).ToList();
			foreach (var searchGroup in allCategories)
			{
				if (commonCategories.Any(c => c.Equals(searchGroup))) continue;
				if (!links.All(l => l.Tags.Categories.Any(c => c.Equals(searchGroup)))) continue;

				var commonCategory = new SearchGroup { Name = searchGroup.Name };
				foreach (var searchTag in allCategories
					.Where(c => c.Equals(commonCategory))
					.SelectMany(c => c.Tags)
					.ToList())
				{
					if (commonCategory.Tags.Any(t => t.Equals(searchTag))) continue;
					if (!links.All(l => l.Tags.Categories
						.Where(c => c.Equals(commonCategory))
						.SelectMany(c => c.Tags)
						.Any(t => t.Equals(searchTag)))) continue;
					commonCategory.Tags.Add(new SearchTag { Name = searchTag.Name });
				}
				if (commonCategory.Tags.Any())
					commonCategories.Add(commonCategory);
			}
			return commonCategories;
		}
Beispiel #38
0
        private void btnSearchGroup_Click(object sender, EventArgs e)
        {
            SearchGroup searchgroupform = new SearchGroup();

            searchgroupform.Show();
        }