#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'ChummerController.O(string)'
        public IActionResult G([FromRoute] string Hash, string open)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'ChummerController.O(string)'
        {
            try
            {
                if (String.IsNullOrEmpty(Hash))
                {
                    throw new ArgumentException("hash is empty: " + Hash);
                }
                var foundseq = (from a in _context.SINnerGroups.Include(a => a.MyGroups) where a.Hash == Hash select a).ToList();
                if (!foundseq.Any())
                {
                    var nullseq = (from a in _context.SINnerGroups where String.IsNullOrEmpty(a.Hash) || a.Hash == "25943ECC" select a).ToList();
                    foreach (var nullSinner in nullseq)
                    {
                        string         message = "Saving Hash for SINner " + nullSinner.Id + ": " + nullSinner.MyHash;
                        TraceTelemetry tt      = new TraceTelemetry(message, SeverityLevel.Verbose);
                        tc?.TrackTrace(tt);
                    }
                }
                foundseq = (from a in _context.SINnerGroups where a.Hash == Hash select a).ToList();
                _context.SaveChanges();
#if DEBUG
                if (Debugger.IsAttached)
                {
                    foundseq = (from a in _context.SINnerGroups select a).Take(1).ToList();
                }
#endif
                if (foundseq.Any())
                {
                    var sgi                         = foundseq.FirstOrDefault();
                    var user                        = _signInManager.UserManager.GetUserAsync(User).Result;
                    SINnerSearchGroup sg            = new SINnerSearchGroup(sgi, user);
                    string            transactionId = String.Format("{0:X}", Guid.NewGuid().ToString().GetHashCode());
                    string            chummerUrl    = "chummer://*****:*****@"<body onload='document.forms[""form""].submit()'>");
                    sb.AppendFormat("<form name='form' action='{0}' method='post'>", postbackUrl);
                    sb.AppendFormat("<input type='hidden' name='guid' value='{0}'>", sg?.Id);
                    sb.AppendFormat("<input type='hidden' name='Environment' value='{0}'>", mypath);
                    sb.AppendFormat("<input type='hidden' name='GroupName' value='{0}'>", sg?.Groupname);
                    sb.AppendFormat("<input type='hidden' name='HasPassword' value='{0}'>", sg?.HasPassword);
                    sb.AppendFormat("<input type='hidden' name='Description' value='{0}'>", sg?.Description);
                    sb.AppendFormat("<input type='hidden' name='IsPublic' value='{0}'>", sg?.IsPublic);
                    sb.AppendFormat("<input type='hidden' name='Language' value='{0}'>", sg?.Language);
                    string urlcallback = "https://shadowsprawl.com/character/status/" + transactionId;
                    string chummeruri  = chummerUrl + ":" + Uri.EscapeDataString(urlcallback);
                    sb.AppendFormat("<input type='hidden' name='ChummerUrl' value='{0}'>", chummeruri);
                    sb.AppendFormat("<input type='hidden' name='TransactionId' value='{0}'>", transactionId);
                    sb.AppendFormat("<input type='hidden' name='StatusCallback' value='{0}'>", urlcallback);
                    sb.AppendFormat("<input type='hidden' name='OpenChummer' value='{0}'>", open);

                    // Other params go here
                    var members = sg.GetGroupMembers(_context, false).Result;
                    var json    = Newtonsoft.Json.JsonConvert.SerializeObject(members, Formatting.Indented);
                    sb.AppendFormat("<input type='hidden' name='Members' value='{0}'>", json);

                    var jsonsubgroups = Newtonsoft.Json.JsonConvert.SerializeObject(sg.MyGroups);
                    sb.AppendFormat("<input type='hidden' name='SubGroups' value='{0}'>", jsonsubgroups);

                    sb.Append("</form>");
                    sb.Append("</body>");
                    sb.Append("</html>");
                    tc.TrackTrace("Form generated: " + sb.ToString(), SeverityLevel.Information);
                    var contentresult = new ContentResult()
                    {
                        ContentType = "text/html",
                        StatusCode  = (int)HttpStatusCode.OK,
                        Content     = sb.ToString()
                    };
                    string msg = "Redirecting Hash " + Hash + " to Shadowsprawl with there parameters: " +
                                 Environment.NewLine + Environment.NewLine;
                    msg += contentresult;
                    TraceTelemetry tt = new TraceTelemetry(msg, SeverityLevel.Verbose);
                    tc?.TrackTrace(tt);
                    return(contentresult);
                }
                return(NotFound("Hash not found."));
            }
            catch (Exception e)
            {
                tc.TrackException(e);
                throw;
            }
        }
Beispiel #2
0
        private async void bCreateGroup_Click(object sender, EventArgs e)
        {
            try
            {
                var group = new SINnerGroup();
                group.Groupname = this.tbSearchGroupname.Text;
                group.IsPublic  = false;
                if ((MyCE.MySINnerFile.MyGroup != null) &&
                    ((String.IsNullOrEmpty(tbSearchGroupname.Text)) ||
                     (tbSearchGroupname.Text == MyCE.MySINnerFile.MyGroup?.Groupname)))
                {
                    group = MyCE.MySINnerFile.MyGroup;
                }
                if (this.lbGroupSearchResult.SelectedItem != null)
                {
                    SINnerSearchGroup sel = lbGroupSearchResult.SelectedItem as SINnerSearchGroup;
                    if (sel != null)
                    {
                        group = new SINnerGroup(sel);
                    }
                }
                frmSINnerGroupEdit ge = new frmSINnerGroupEdit(group, false);
                var result            = ge.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    try
                    {
                        using (new CursorWait(false, this))
                        {
                            if (group == MyCE.MySINnerFile.MyGroup)
                            {
                                var client = await StaticUtils.GetClient();

                                var response = await client.PostGroupWithHttpMessagesAsync(group, MyCE.MySINnerFile.Id);

                                if ((response.Response.StatusCode == HttpStatusCode.Accepted) ||
                                    (response.Response.StatusCode == HttpStatusCode.Created) ||
                                    (response.Response.StatusCode == HttpStatusCode.OK))
                                {
                                    //ok
                                }
                                else if ((response.Response.StatusCode == HttpStatusCode.NotFound))
                                {
                                    var rescontent = await response.Response.Content.ReadAsStringAsync();

                                    string msg = "StatusCode: " + response.Response.StatusCode + Environment.NewLine;
                                    msg += rescontent;
                                    throw new ArgumentNullException(nameof(group), msg);
                                }
                                else
                                {
                                    var rescontent = await response.Response.Content.ReadAsStringAsync();

                                    throw new ArgumentException(rescontent);
                                }
                            }
                            else
                            {
                                //create mode

                                var a = await CreateGroup(ge.MySINnerGroupCreate.MyGroup);

                                if (a != null)
                                {
                                    MySINSearchGroupResult = await SearchForGroups(a.Groupname, null, null);

                                    if (MyParentForm?.MyParentForm != null)
                                    {
                                        await MyParentForm.MyParentForm.CheckSINnerStatus();
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError(ex.ToString(), ex);
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #3
0
        private static TreeNode GetCharacterRosterTreeNodeRecursive(SINnerSearchGroup ssg)
        {
            TreeNode objListNode = new TreeNode
            {
                Text = ssg.Groupname,
                Name = ssg.Groupname
            };

            foreach (var member in ssg.MyMembers)
            {
                var sinner = member.MySINner;
                sinner.DownloadedFromSINnersTime = DateTime.Now;
                CharacterCache objCache = null;
                if (!String.IsNullOrEmpty(sinner?.MyExtendedAttributes?.JsonSummary))
                {
                    objCache =
                        Newtonsoft.Json.JsonConvert.DeserializeObject <CharacterCache>(sinner.MyExtendedAttributes
                                                                                       .JsonSummary);
                }
                else
                {
                    objCache = new CharacterCache
                    {
                        CharacterName  = "pending",
                        CharacterAlias = sinner.Alias,
                        BuildMethod    = "online"
                    };
                }

                SetEventHandlers(sinner, objCache);
                TreeNode memberNode = new TreeNode
                {
                    Text             = objCache.CalculatedName(),
                    Name             = objCache.CalculatedName(),
                    Tag              = sinner.Id.Value.ToString(),
                    ToolTipText      = "Last Change: " + sinner.LastChange,
                    ContextMenuStrip = PluginHandler.MainForm.CharacterRoster.ContextMenuStrip
                };
                if (String.IsNullOrEmpty(sinner.DownloadUrl))
                {
                    objCache.ErrorText = "File is not uploaded - only metadata available." + Environment.NewLine
                                         + "Please upload this file again from a client," +
                                         Environment.NewLine
                                         + "that has saved a local copy." +
                                         Environment.NewLine + Environment.NewLine
                                         + "Open the character locally, make sure to have \"online mode\"" +
                                         Environment.NewLine
                                         + "selected in option->plugins->sinner and press the \"save\" symbol.";
                }
                if (!objListNode.Nodes.ContainsKey(memberNode.Name))
                {
                    objListNode.Nodes.Insert(0, memberNode);
                }
                if (!string.IsNullOrEmpty(objCache.ErrorText))
                {
                    memberNode.ForeColor    = Color.Red;
                    memberNode.ToolTipText += Environment.NewLine + Environment.NewLine +
                                              LanguageManager.GetString("String_Error", GlobalOptions.Language)
                                              + LanguageManager.GetString("String_Colon", GlobalOptions.Language) +
                                              Environment.NewLine + objCache.ErrorText;
                }

                CharacterCache delObj;
                PluginHandler.MainForm.CharacterRoster.MyCharacterCacheDic.TryRemove(sinner.Id.Value.ToString(), out delObj);
                PluginHandler.MainForm.CharacterRoster.MyCharacterCacheDic.TryAdd(sinner.Id.Value.ToString(), objCache);
                if (ssg.MySINSearchGroups != null)
                {
                    foreach (var childlist in ssg.MySINSearchGroups)
                    {
                        var childnode = GetCharacterRosterTreeNodeRecursive(childlist);
                        if (childnode != null)
                        {
                            if (!objListNode.Nodes.ContainsKey(childnode.Text))
                            {
                                objListNode.Nodes.Add(childnode);
                            }
                        }
                    }
                }
            }

            if (ssg.MySINSearchGroups != null)
            {
                foreach (var childssg in ssg.MySINSearchGroups)
                {
                    var childnode = GetCharacterRosterTreeNodeRecursive(childssg);
                    if (childnode != null)
                    {
                        if (!objListNode.Nodes.ContainsKey(childnode.Name))
                        {
                            objListNode.Nodes.Add(childnode);
                        }
                        else
                        {
                            var list = objListNode.Nodes.Find(childnode.Name, false).ToList();
                            foreach (var mergenode in list)
                            {
                                foreach (TreeNode what in childnode.Nodes)
                                {
                                    if (!mergenode.Nodes.ContainsKey(what.Name))
                                    {
                                        mergenode.Nodes.Add(what);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(objListNode);
        }
Beispiel #4
0
        private async void bJoinGroup_Click(object sender, EventArgs e)
        {
            if (lbGroupSearchResult.SelectedItem == null)
            {
                return;
            }

            try
            {
                using (new CursorWait(false, this))
                {
                    SINnerSearchGroup item = lbGroupSearchResult.SelectedItem as SINnerSearchGroup;
                    if (MyCE.MySINnerFile.MyGroup != null)
                    {
                        await LeaveGroupTask(MyCE.MySINnerFile, MyCE.MySINnerFile.MyGroup, item != null);
                    }

                    if (item == null)
                    {
                        return;
                    }

                    var uploadtask = MyCE.Upload();
                    await uploadtask.ContinueWith(b =>
                    {
                        using (new CursorWait(false, this))
                        {
                            var task = JoinGroupTask(item, MyCE);
                            task.ContinueWith(a =>
                            {
                                using (new CursorWait(false, this))
                                {
                                    if (a.IsFaulted)
                                    {
                                        string msg = "JoinGroupTask returned faulted!";
                                        if ((a.Exception != null) && (a.Exception is AggregateException))
                                        {
                                            msg = "";
                                            foreach (var exp in (a.Exception as AggregateException).InnerExceptions)
                                            {
                                                msg += exp.Message + Environment.NewLine;
                                            }
                                        }
                                        else
                                        {
                                            if (a.Exception != null)
                                            {
                                                msg = a.Exception.Message;
                                            }
                                        }

                                        MessageBox.Show(msg);
                                        return;
                                    }

                                    if (!String.IsNullOrEmpty(a.Result?.ErrorText))
                                    {
                                        System.Diagnostics.Trace.TraceError(a.Result.ErrorText);
                                    }
                                    else
                                    {
                                        MyCE.MySINnerFile.MyGroup = new SINnerGroup(item);
                                        //if (OnGroupJoinCallback != null)
                                        //    OnGroupJoinCallback(this, item.MyParentGroup);
                                        System.Diagnostics.Trace.TraceInformation(
                                            "Char " + MyCE.MyCharacter.CharacterName + " joined group " +
                                            item.Groupname +
                                            ".");
                                        TlpGroupSearch_VisibleChanged(null, new EventArgs());
                                    }
                                }
                            });
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError(ex.Message, ex);
                throw;
            }
        }
Beispiel #5
0
        private async Task <SINSearchGroupResult> JoinGroupTask(SINnerSearchGroup searchgroup, CharacterExtended myCE)
        {
            bool exceptionlogged      = false;
            SINSearchGroupResult ssgr = null;

            try
            {
                SINnerGroup        joinGroup = new SINnerGroup(searchgroup);
                DialogResult       result    = DialogResult.Cancel;
                frmSINnerGroupEdit groupEdit = null;
                PluginHandler.MainForm.DoThreadSafe(() =>
                {
                    groupEdit = new frmSINnerGroupEdit(joinGroup, true);
                    result    = groupEdit.ShowDialog(this);
                });
                if (result == DialogResult.OK)
                {
                    try
                    {
                        using (new CursorWait(true, this))
                        {
                            var client = await StaticUtils.GetClient();

                            var response =
                                await client.PutSINerInGroupWithHttpMessagesAsync(searchgroup.Id, myCE.MySINnerFile.Id,
                                                                                  groupEdit.MySINnerGroupCreate.MyGroup.PasswordHash);

                            if ((response.Response.StatusCode != HttpStatusCode.OK))
                            {
                                var rescontent = await response.Response.Content.ReadAsStringAsync();

                                if (response.Response.StatusCode == HttpStatusCode.BadRequest)
                                {
                                    if (rescontent.Contains("PW is wrong!"))
                                    {
                                        throw new ArgumentException("Wrong Password provided!");
                                    }

                                    string searchfor = "NoUserRightException\",\"Message\":\"";
                                    if (rescontent.Contains(searchfor))
                                    {
                                        string msg =
                                            rescontent.Substring(rescontent.IndexOf(searchfor) + searchfor.Length);
                                        msg = msg.Substring(0, msg.IndexOf("\""));
                                        throw new ArgumentException(msg);
                                    }

                                    throw new ArgumentException(rescontent);
                                }
                                else
                                {
                                    string msg = "StatusCode: " + response.Response.StatusCode + Environment.NewLine;
                                    msg += rescontent;
                                    throw new ArgumentException(msg);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Trace.TraceInformation(e.Message, e);
                        exceptionlogged = true;
                        throw;
                    }
                    finally
                    {
                        MyParentForm?.MyParentForm?.CheckSINnerStatus();
                    }
                }
            }
            catch (Exception e)
            {
                if (!exceptionlogged)
                {
                    System.Diagnostics.Trace.TraceError(e.Message, e);
                }
                throw;
            }


            return(ssgr);
        }
Beispiel #6
0
        private async Task <List <SINnerSearchGroup> > RecursiveBuildGroupMembers(IEnumerable <SINnerGroup> groupworklist, ApplicationUser user)
        {
            List <SINnerSearchGroup> addlist = new List <SINnerSearchGroup>();

            foreach (var singroup in groupworklist.ToList())
            {
                if (singroup == null)
                {
                    continue;
                }
                SINnerSearchGroup ssgFromSIN = addlist.FirstOrDefault(a => a.Id != null && a.Id == singroup.Id);
                if (ssgFromSIN == null)
                {
                    if (singroup.Id == null)
                    {
                        _context.SINnerGroups.Remove(singroup);
                        continue;
                    }
                    ssgFromSIN = new SINnerSearchGroup(singroup, user);
                    addlist.Add(ssgFromSIN);
                    //for all groups in this group
                    ssgFromSIN.MySINSearchGroups = await RecursiveBuildGroupMembers(singroup.MyGroups, user);
                }

                //add all members of his group
                var members = await singroup.GetGroupMembers(_context, false);

                foreach (var member in members)
                {
                    if (singroup.IsPublic != true)
                    {
                        if (member.SINnerMetaData?.Visibility?.IsGroupVisible == false)
                        {
                            if (member.SINnerMetaData?.Visibility.UserRights.Any(a =>
                                                                                 string.IsNullOrEmpty(a.EMail) == false) == true)
                            {
                                if (member.SINnerMetaData?.Visibility.UserRights.Any(a =>
                                                                                     a.EMail?.ToUpperInvariant() == user.NormalizedEmail) == false)
                                {
                                    //dont show this guy!
                                    continue;
                                }
                            }
                        }
                    }

                    member.LastDownload     = DateTime.Now;
                    member.MyGroup          = singroup;
                    member.MyGroup.MyGroups = new List <SINnerGroup>();
                    SINnerSearchGroupMember sinssgGroupMember = new SINnerSearchGroupMember(user, member)
                    {
                        MySINner = member
                    };
                    //check if it is already added:
                    if (ssgFromSIN.MyMembers.Any(a => a.MySINner == member))
                    {
                        continue;
                    }
                    ssgFromSIN.MyMembers.Add(sinssgGroupMember);
                }

                singroup.PasswordHash = string.Empty;
                singroup.MyGroups     = new List <SINnerGroup>();
            }

            return(addlist);
        }
Beispiel #7
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'AccountController.GetSinnerAsAdmin()'
        public async Task <ActionResult <ResultGroupGetSearchGroups> > GetSinnerAsAdmin()
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'AccountController.GetSinnerAsAdmin()'
        {
            SINSearchGroupResult ret = new SINSearchGroupResult();
            ResultAccountGetSinnersByAuthorization res = new ResultAccountGetSinnersByAuthorization(ret);
            SINnerGroup sg   = new SINnerGroup();
            var         user = await _signInManager.UserManager.GetUserAsync(User);

            if (user == null)
            {
                var e = new AuthenticationException("User is not authenticated.");
                res = new ResultAccountGetSinnersByAuthorization(e)
                {
                    ErrorText = "Unauthorized"
                };
                return(BadRequest(res));
            }
            user.FavoriteGroups = user.FavoriteGroups.GroupBy(a => a.FavoriteGuid).Select(b => b.First()).ToList();

            SINnerSearchGroup ssg = new SINnerSearchGroup(sg, user)
            {
                MyMembers = new List <SINnerSearchGroupMember>()
            };

            try
            {
                var roles = await _userManager.GetRolesAsync(user);

                ret.Roles     = roles.ToList();
                ssg.Groupname = user.Email;
                ssg.Id        = Guid.Empty;
                //get all from visibility
                List <SINner> mySinners = await _context.SINners.Include(a => a.MyGroup)
                                          .Include(a => a.SINnerMetaData.Visibility.UserRights)
                                          .OrderByDescending(a => a.UploadDateTime)
                                          .Take(200)
                                          .ToListAsync();

                foreach (var sin in mySinners)
                {
                    SINnerSearchGroupMember ssgm = new SINnerSearchGroupMember(user, sin);
                    ssg.MyMembers.Add(ssgm);
                    if (sin.MyGroup != null)
                    {
                        SINnerSearchGroup ssgFromSIN = ssg.MySINSearchGroups.FirstOrDefault(a => a.Id == sin.MyGroup.Id);
                        if (ssgFromSIN == null)
                        {
                            ssgFromSIN = new SINnerSearchGroup(sin.MyGroup, user);
                            ssg.MySINSearchGroups.Add(ssgFromSIN);
                        }
                        //add all members of his group
                        var members = await sin.MyGroup.GetGroupMembers(_context, false);

                        foreach (var member in members)
                        {
                            member.MyGroup          = sin.MyGroup;
                            member.MyGroup.MyGroups = new List <SINnerGroup>();
                            SINnerSearchGroupMember sinssgGroupMember = new SINnerSearchGroupMember(user, member);
                            ssgFromSIN.MyMembers.Add(sinssgGroupMember);
                        }
                        sin.MyGroup.PasswordHash = string.Empty;
                        sin.MyGroup.MyGroups     = new List <SINnerGroup>();
                    }
                }

                ret.SINGroups.Add(ssg);
                res = new ResultAccountGetSinnersByAuthorization(ret);
                return(Ok(res));
            }
            catch (Exception e)
            {
                try
                {
                    await _signInManager.UserManager.GetUserAsync(User);

                    //var tc = new Microsoft.ApplicationInsights.TelemetryClient();
                    ExceptionTelemetry et = new ExceptionTelemetry(e);
                    et.Properties.Add("user", User.Identity.Name);
                    tc.TrackException(et);
                }
                catch (Exception ex)
                {
                    _logger?.LogError(ex.ToString());
                }
                res = new ResultAccountGetSinnersByAuthorization(e);
                return(BadRequest(res));
            }
        }
Beispiel #8
0
        private async void TvGroupSearchResult_DragDrop(object sender, DragEventArgs e)
        {
            // Retrieve the client coordinates of the drop location.
            Point targetPoint = tvGroupSearchResult.PointToClient(new Point(e.X, e.Y));

            // Retrieve the node at the drop location.
            TreeNode targetNode = tvGroupSearchResult.GetNodeAt(targetPoint);

            // Retrieve the node that was dragged.
            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

            // Sanity check
            if (draggedNode == null)
            {
                return;
            }
            SINnerSearchGroup       draggedGroup  = draggedNode.Tag as SINnerSearchGroup;
            SINnerSearchGroupMember draggedSINner = draggedNode.Tag as SINnerSearchGroupMember;
            SINnerSearchGroup       targetGroup   = null;
            TreeNode parentNode = targetNode;

            // Did the user drop on a valid target node?
            if (targetNode != null)
            {
                targetGroup = parentNode.Tag as SINnerSearchGroup;

                while (targetGroup == null && parentNode.Parent != null)
                {
                    parentNode  = parentNode.Parent;
                    targetGroup = parentNode.Tag as SINnerSearchGroup;
                }
            }

            // Confirm that the node at the drop location is not
            // the dragged node and that target node isn't null
            // (for example if you drag outside the control)
            if (!draggedNode.Equals(targetNode) /* && targetNode != null*/)
            {
                bool canDrop = true;

                // Crawl our way up from the node we dropped on to find out if
                // if the target node is our parent.
                while (canDrop && (parentNode != null) && (targetGroup == null))
                {
                    canDrop     = !Object.ReferenceEquals(draggedNode, parentNode);
                    parentNode  = parentNode.Parent;
                    targetGroup = parentNode?.Tag as SINnerSearchGroup;
                    targetNode  = parentNode;
                }

                // Is this a valid drop location?
                if (canDrop)
                {
                    // Yes. Move the node, expand it, and select it.

                    var client = StaticUtils.GetClient();
                    if (draggedGroup != null)
                    {
                        var res = await client.PutGroupInGroupWithHttpMessagesAsync(draggedGroup.Id,
                                                                                    draggedGroup.Groupname, targetGroup?.Id,
                                                                                    draggedGroup.MyAdminIdentityRole, draggedGroup.IsPublic);

                        if (res.Response.StatusCode == HttpStatusCode.OK)
                        {
                            MoveNode(draggedNode, targetNode);
                        }
                    }
                    if ((draggedSINner?.MySINner?.MyGroup != null) && (targetGroup != null))
                    {
                        if (targetGroup.Groupname == "My SINners")
                        {
                            var res = await client.DeleteLeaveGroupWithHttpMessagesAsync(
                                draggedSINner.MySINner.MyGroup.Id, draggedSINner.MySINner.Id);

                            var response = Backend.Utils.HandleError(res, res.Body);
                            if (res.Response.StatusCode == HttpStatusCode.OK)
                            {
                                bSearch_Click(sender, e);
                            }
                        }
                        if ((draggedSINner.MySINner.MyGroup?.Id == targetGroup.Id))
                        {
                            return;
                        }
                        if (draggedSINner.MySINner.MyGroup == null && targetGroup.Id == null)
                        {
                            return;
                        }

                        try
                        {
                            var res = await client.PutSINerInGroupWithHttpMessagesAsync(targetGroup.Id, draggedSINner.MySINner.Id);

                            var response = Backend.Utils.HandleError(res, res.Body);
                            if (res.Response.StatusCode == HttpStatusCode.OK)
                            {
                                bSearch_Click(sender, e);
                            }
                        }
                        catch (Exception exception)
                        {
                            await Backend.Utils.HandleError(exception);
                        }
                    }

                    if ((draggedSINner?.MySINner?.MyGroup?.Id != null) && (targetNode == null))
                    {
                        var res = await client.DeleteLeaveGroupWithHttpMessagesAsync(
                            draggedSINner.MySINner.MyGroup.Id, draggedSINner.MySINner.Id);

                        var response = Backend.Utils.HandleError(res, res.Body);
                        if (res.Response.StatusCode == HttpStatusCode.OK)
                        {
                            MoveNode(draggedNode, targetNode);
                        }
                    }
                    else if ((draggedSINner?.MySINner != null && (targetNode == null)))
                    {
                        var res = await client.PutSINerInGroupWithHttpMessagesAsync(null, draggedSINner.MySINner.Id);

                        var response = Backend.Utils.HandleError(res, res.Body);
                        if (res.Response.StatusCode == HttpStatusCode.OK)
                        {
                            MoveNode(draggedNode, targetNode);
                        }
                    }
                    else if (draggedSINner != null && targetGroup != null)
                    {
                        var res = await client.PutSINerInGroupWithHttpMessagesAsync(targetGroup.Id, draggedSINner.MySINner.Id);

                        var response = Backend.Utils.HandleError(res, res.Body);
                        if (res.Response.StatusCode == HttpStatusCode.OK)
                        {
                            MoveNode(draggedNode, targetNode);
                        }
                    }
                }
            }

            // Optional: Select the dropped node and navigate (however you do it)
            tvGroupSearchResult.SelectedNode = draggedNode;
            // NavigateToContent(draggedNode.Tag);
        }
Beispiel #9
0
        private async Task <ActionResult <ResultAccountGetSinnersByAuthorization> > GetSINnersByAuthorizationInternal()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            //var tc = new Microsoft.ApplicationInsights.TelemetryClient();
            ResultAccountGetSinnersByAuthorization res = null;

            SINSearchGroupResult ret = new SINSearchGroupResult();

            res = new ResultAccountGetSinnersByAuthorization(ret);
            SINnerGroup sg   = new SINnerGroup();
            var         user = await _signInManager.UserManager.GetUserAsync(User);

            if (user == null)
            {
                var e = new AuthenticationException("User is not authenticated.");
                res = new ResultAccountGetSinnersByAuthorization(e)
                {
                    ErrorText = "Unauthorized"
                };
                return(BadRequest(res));
            }
            user.FavoriteGroups = user.FavoriteGroups.GroupBy(a => a.FavoriteGuid).Select(b => b.First()).ToList();

            SINnerSearchGroup ssg = new SINnerSearchGroup(sg, user)
            {
                MyMembers = new List <SINnerSearchGroupMember>()
            };

            using (var t = new TransactionScope(TransactionScopeOption.Required,
                                                new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadUncommitted
            }, TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var roles = await _userManager.GetRolesAsync(user);

                    ret.Roles     = roles.ToList();
                    ssg.Groupname = user.UserName;
                    ssg.Id        = Guid.Empty;
                    var worklist      = user.FavoriteGroups.Select(a => a.FavoriteGuid).ToList();
                    var groupworklist = _context.SINnerGroups
                                        .Include(a => a.MyGroups)
                                        .ThenInclude(b => b.MyGroups)
                                        .ThenInclude(c => c.MyGroups)
                                        .ThenInclude(d => d.MyGroups)
                                        .Where(a => a.Id != null && worklist.Contains(a.Id.Value)).ToList();
                    ssg.MySINSearchGroups = await RecursiveBuildGroupMembers(groupworklist, user);

                    var memberworklist = _context.SINners
                                         .Include(a => a.MyGroup)
                                         .Include(a => a.SINnerMetaData.Visibility)
                                         .Where(a => a.Id != null && worklist.Contains(a.Id.Value));
                    foreach (var member in memberworklist)
                    {
                        if (member.SINnerMetaData?.Visibility?.IsGroupVisible == false)
                        {
                            if (member.SINnerMetaData?.Visibility.UserRights.Any(a =>
                                                                                 !string.IsNullOrEmpty(a.EMail)) == true)
                            {
                                if (member.SINnerMetaData?.Visibility.UserRights.Any(a =>
                                                                                     user.NormalizedEmail.Equals(a.EMail, StringComparison.OrdinalIgnoreCase)) == false)
                                {
                                    //dont show this guy!
                                    continue;
                                }
                            }
                        }

                        member.LastDownload = DateTime.Now;
                        if (member.MyGroup == null)
                        {
                            member.MyGroup = new SINnerGroup();
                        }
                        if (member.MyGroup.MyGroups == null)
                        {
                            member.MyGroup.MyGroups = new List <SINnerGroup>();
                        }
                        SINnerSearchGroupMember sinssgGroupMember = new SINnerSearchGroupMember(user, member)
                        {
                            MySINner = member
                        };
                        ssg.MyMembers.Add(sinssgGroupMember);
                    }

                    await _context.SaveChangesAsync();

                    ret.SINGroups.Add(ssg);
                    res = new ResultAccountGetSinnersByAuthorization(ret);
                    return(Ok(res));
                }
                catch (Exception e)
                {
                    try
                    {
                        await _signInManager.UserManager.GetUserAsync(User);

                        ExceptionTelemetry et = new ExceptionTelemetry(e);
                        et.Properties.Add("user", User.Identity.Name);
                        tc.TrackException(et);
                    }
                    catch (Exception ex)
                    {
                        _logger?.LogError(ex.ToString());
                    }

                    res = new ResultAccountGetSinnersByAuthorization(e);
                    return(BadRequest(res));
                }
                finally
                {
                    AvailabilityTelemetry telemetry = new AvailabilityTelemetry("GetSINnersByAuthorization", DateTimeOffset.Now, sw.Elapsed, "Azure", res.CallSuccess, res.ErrorText);
                    tc?.TrackAvailability(telemetry);
                }
            }
        }
Beispiel #10
0
        private async void bJoinGroup_Click(object sender, EventArgs e)
        {
            if (MyCE == null)
            {
                return;
            }
            if (tvGroupSearchResult.SelectedNode == null)
            {
                return;
            }

            try
            {
                using (new CursorWait(false, this))
                {
                    SINnerSearchGroup item = tvGroupSearchResult.SelectedNode.Tag as SINnerSearchGroup;
                    if (MyCE.MySINnerFile.MyGroup != null)
                    {
                        await LeaveGroupTask(MyCE.MySINnerFile, MyCE.MySINnerFile.MyGroup, item != null);
                    }

                    if (item == null)
                    {
                        return;
                    }

                    //var uploadtask = MyCE.Upload();
                    //await uploadtask.ContinueWith(b =>
                    //{
                    using (new CursorWait(false, this))
                    {
                        var task = JoinGroupTask(item, MyCE);
                        await task.ContinueWith(a =>
                        {
                            using (new CursorWait(false, this))
                            {
                                if (a.IsFaulted)
                                {
                                    string msg = "JoinGroupTask returned faulted!";
                                    if ((a.Exception != null) && (a.Exception is AggregateException))
                                    {
                                        msg = "";
                                        foreach (var exp in (a.Exception as AggregateException).InnerExceptions)
                                        {
                                            msg += exp.Message + Environment.NewLine;
                                        }
                                    }
                                    else
                                    {
                                        if (a.Exception != null)
                                        {
                                            msg = a.Exception.Message;
                                        }
                                    }

                                    Program.MainForm.ShowMessageBox(msg);
                                    return;
                                }

                                if (!String.IsNullOrEmpty(a.Result?.ErrorText))
                                {
                                    Log.Error(a.Result.ErrorText);
                                }
                                else if (a.Result == null)
                                {
                                    MyCE.MySINnerFile.MyGroup = null;
                                    string msg = "Char " + MyCE.MyCharacter.CharacterName + " did not join group " +
                                                 item.Groupname +
                                                 ".";
                                    Log.Info(msg);
                                    this.DoThreadSafe(() =>
                                    {
                                        Program.MainForm.ShowMessageBox(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        TlpGroupSearch_VisibleChanged(null, new EventArgs());
                                    });
                                }
                                else
                                {
                                    MyCE.MySINnerFile.MyGroup = new SINnerGroup(item);
                                    //if (OnGroupJoinCallback != null)
                                    //    OnGroupJoinCallback(this, MyCE.MySINnerFile.MyGroup);
                                    string msg = "Char " + MyCE.MyCharacter.CharacterName + " joined group " +
                                                 item.Groupname +
                                                 ".";
                                    Log.Info(msg);
                                    this.DoThreadSafe(() =>
                                    {
                                        Program.MainForm.ShowMessageBox(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        TlpGroupSearch_VisibleChanged(null, new EventArgs());
                                    });
                                    PluginHandler.MainForm.CharacterRoster.DoThreadSafe(() =>
                                    {
                                        PluginHandler.MainForm.CharacterRoster.LoadCharacters(false, false, false, true);
                                    });
                                }
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
Beispiel #11
0
        private async Task <ActionResult <ResultAccountGetSinnersByAuthorization> > GetSINnersByAuthorizationInternal()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            //var tc = new Microsoft.ApplicationInsights.TelemetryClient();
            ResultAccountGetSinnersByAuthorization res = null;

            SINSearchGroupResult ret = new SINSearchGroupResult();

            res = new ResultAccountGetSinnersByAuthorization(ret);
            SINnerGroup       sg  = new SINnerGroup();
            SINnerSearchGroup ssg = new SINnerSearchGroup(sg)
            {
                MyMembers = new List <SINnerSearchGroupMember>()
            };

            using (var t = new TransactionScope(TransactionScopeOption.Required,
                                                new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
            }, TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var user = await _signInManager.UserManager.GetUserAsync(User);

                    if (user == null)
                    {
                        var e = new AuthenticationException("User is not authenticated.");
                        res = new ResultAccountGetSinnersByAuthorization(e)
                        {
                            ErrorText = "Unauthorized"
                        };
                        return(BadRequest(res));
                    }

                    var roles = await _userManager.GetRolesAsync(user);

                    ret.Roles     = roles.ToList();
                    ssg.Groupname = user.UserName;
                    ssg.Id        = Guid.Empty;
                    //get all from visibility
                    List <SINner> mySinners = await SINner.GetSINnersFromUser(user, _context, true);

                    MetricTelemetry mt = new MetricTelemetry("GetSINersByAuthorization", "SINners found",
                                                             mySinners.Count, 0, 0, 0, 0);
                    tc.TrackMetric(mt);
                    foreach (var sin in mySinners)
                    {
                        //check if that char is already added:
                        var foundseq = (from a in ssg.MyMembers where a.MySINner.Id == sin.Id select a);
                        if (foundseq.Any())
                        {
                            continue;
                        }
                        sin.LastDownload = DateTime.Now;
                        SINnerSearchGroupMember ssgm = new SINnerSearchGroupMember
                        {
                            MySINner = sin,
                            Username = user.UserName
                        };
                        if (sin.MyGroup?.Id != null)
                        {
                            if (!user.FavoriteGroups.Any(a => a.FavoriteGuid == sin.MyGroup.Id.Value))
                            {
                                user.FavoriteGroups.Add(new ApplicationUserFavoriteGroup()
                                {
                                    FavoriteGuid = sin.MyGroup.Id.Value
                                });
                            }
                        }
                        else
                        {
                            ssg.MyMembers.Add(ssgm);
                        }
                    }

                    user.FavoriteGroups = user.FavoriteGroups.GroupBy(a => a.FavoriteGuid).Select(b => b.First()).ToList();


                    foreach (var singroupId in user.FavoriteGroups)
                    {
                        SINnerSearchGroup ssgFromSIN;
                        var singroup = await _context.SINnerGroups.FirstOrDefaultAsync(a => a.Id == singroupId.FavoriteGuid);

                        if (ssg.MySINSearchGroups.Any(a => a.Id == singroupId.FavoriteGuid))
                        {
                            ssgFromSIN = ssg.MySINSearchGroups.FirstOrDefault(a => a.Id == singroupId.FavoriteGuid);
                        }
                        else
                        {
                            ssgFromSIN = new SINnerSearchGroup(singroup);
                            ssg.MySINSearchGroups.Add(ssgFromSIN);
                        }

                        //add all members of his group
                        var members = await singroup.GetGroupMembers(_context, false);

                        foreach (var member in members)
                        {
                            member.LastDownload     = DateTime.Now;
                            member.MyGroup          = singroup;
                            member.MyGroup.MyGroups = new List <SINnerGroup>();
                            SINnerSearchGroupMember sinssgGroupMember = new SINnerSearchGroupMember
                            {
                                MySINner = member
                            };
                            //check if it is already added:
                            var groupseq = from a in ssgFromSIN.MyMembers where a.MySINner == member select a;
                            if (groupseq.Any())
                            {
                                continue;
                            }
                            ssgFromSIN.MyMembers.Add(sinssgGroupMember);
                            //}
                        }

                        singroup.PasswordHash = "";
                        singroup.MyGroups     = new List <SINnerGroup>();
                    }
                    await _context.SaveChangesAsync();

                    ret.SINGroups.Add(ssg);
                    res = new ResultAccountGetSinnersByAuthorization(ret);

                    return(Ok(res));
                }
                catch (Exception e)
                {
                    try
                    {
                        var user = await _signInManager.UserManager.GetUserAsync(User);

                        ExceptionTelemetry et = new ExceptionTelemetry(e);
                        et.Properties.Add("user", User.Identity.Name);
                        tc.TrackException(et);
                    }
                    catch (Exception ex)
                    {
                        _logger?.LogError(ex.ToString());
                    }

                    res = new ResultAccountGetSinnersByAuthorization(e);
                    return(BadRequest(res));
                }
                finally
                {
                    Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry telemetry =
                        new Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry("GetSINnersByAuthorization",
                                                                                              DateTimeOffset.Now, sw.Elapsed, "Azure", res?.CallSuccess ?? false, res?.ErrorText);
                    tc.TrackAvailability(telemetry);
                }

#pragma warning disable CS0162 // Unreachable code detected
                t.Complete();
#pragma warning restore CS0162 // Unreachable code detected
            }
        }
        private async Task <ActionResult <SINSearchGroupResult> > GetSearchGroupsInternal(string Groupname, string UsernameOrEmail, string sINnerName, string language)
        {
            ApplicationUser user = null;

            try
            {
                if (!ModelState.IsValid)
                {
                    var errors = ModelState.Select(x => x.Value.Errors)
                                 .Where(y => y.Count > 0)
                                 .ToList();
                    string msg = "ModelState is invalid: ";
                    foreach (var err in errors)
                    {
                        foreach (var singleerr in err)
                        {
                            msg += Environment.NewLine + "\t" + singleerr.ToString();
                        }
                    }

                    return(BadRequest(new HubException(msg)));
                }

                SINSearchGroupResult result = new SINSearchGroupResult();
                var groupfoundseq           = await(from a in _context.SINnerGroups
                                                    where a.Groupname.ToLowerInvariant().Contains(Groupname.ToLowerInvariant()) &&
                                                    (a.Language == language || String.IsNullOrEmpty(language))
                                                    select a.Id).ToListAsync();
                if (!groupfoundseq.Any())
                {
                    return(NotFound(Groupname));
                }

                foreach (var groupid in groupfoundseq)
                {
                    var ssg = await GetSinSearchGroupResultById(groupid);

                    result.SINGroups.Add(ssg);
                }

                if (!String.IsNullOrEmpty(UsernameOrEmail))
                {
                    List <SINner>   byUser     = new List <SINner>();
                    ApplicationUser bynameuser = await _userManager.FindByNameAsync(UsernameOrEmail);

                    if (bynameuser != null)
                    {
                        var usersinners = await SINner.GetSINnersFromUser(bynameuser, _context, true);

                        byUser.AddRange(usersinners);
                    }

                    ApplicationUser byemailuser = await _userManager.FindByEmailAsync(UsernameOrEmail);

                    if ((byemailuser != null) && (byemailuser != bynameuser))
                    {
                        var usersinners = await SINner.GetSINnersFromUser(byemailuser, _context, true);

                        byUser.AddRange(usersinners);
                    }


                    foreach (var sin in byUser)
                    {
                        if (sin.MyGroup != null)
                        {
                            SINnerSearchGroup ssg = null;
                            var foundseq          = (from a in result.SINGroups
                                                     where a.Groupname?.ToLowerInvariant() == sin.MyGroup?.Groupname.ToLowerInvariant()
                                                     select a).ToList();
                            if (foundseq.Any())
                            {
                                ssg = foundseq.FirstOrDefault();
                            }

                            if (ssg == null)
                            {
                                ssg = new SINnerSearchGroup(sin.MyGroup);
                            }
                            ssg.Id = sin.MyGroup?.Id;
                            SINnerSearchGroupMember ssgm = new SINnerSearchGroupMember();
                            ssgm.MySINner = sin;
                            if (byemailuser != null)
                            {
                                ssgm.Username = byemailuser?.UserName;
                            }
                            if (bynameuser != null)
                            {
                                ssgm.Username = bynameuser?.UserName;
                            }
                            ssg.MyMembers.Add(ssgm);
                        }
                    }
                }
                result.SINGroups = RemovePWHashRecursive(result.SINGroups);

                return(Ok(result));
            }
            catch (Exception e)
            {
                try
                {
                    var tc = new Microsoft.ApplicationInsights.TelemetryClient();
                    Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry telemetry = new Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry(e);
                    telemetry.Properties.Add("User", user?.Email);
                    telemetry.Properties.Add("Groupname", Groupname?.ToString());
                    tc.TrackException(telemetry);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.ToString());
                }
                if (e is HubException)
                {
                    return(BadRequest(e));
                }
                HubException hue = new HubException("Exception in GetSearchGroups: " + e.Message, e);
                return(BadRequest(hue));
            }
        }
Beispiel #13
0
        public async Task <ActionResult <SINSearchGroupResult> > GetSINnersByAuthorization()
        {
            SINSearchGroupResult ret = new SINSearchGroupResult();
            SINnerGroup          sg  = new SINnerGroup();
            SINnerSearchGroup    ssg = new SINnerSearchGroup(sg)
            {
                MyMembers = new List <SINnerSearchGroupMember>()
            };

            try
            {
                var user = await _signInManager.UserManager.GetUserAsync(User);

                if (user == null)
                {
                    ret.ErrorText = "Unauthorized";
                    throw new AuthenticationException("User is not authenticated.");
                }
                var roles = await _userManager.GetRolesAsync(user);

                ret.Roles     = roles.ToList();
                ssg.Groupname = user.Email;
                ssg.Id        = Guid.Empty;
                //get all from visibility
                //SINnersList list = new SINnersList();
                List <SINner> mySinners = await SINner.GetSINnersFromUser(user, _context, true);

                foreach (var sin in mySinners)
                {
                    SINnerSearchGroupMember ssgm = new SINnerSearchGroupMember
                    {
                        MySINner = sin,
                        Username = user.UserName
                    };
                    ssg.MyMembers.Add(ssgm);
                    if (sin.MyGroup != null)
                    {
                        SINnerSearchGroup ssgFromSIN;
                        if (ssg.MySINSearchGroups.Any(a => a.Id == sin.MyGroup.Id))
                        {
                            ssgFromSIN = ssg.MySINSearchGroups.FirstOrDefault(a => a.Id == sin.MyGroup.Id);
                        }
                        else
                        {
                            ssgFromSIN = new SINnerSearchGroup(sin.MyGroup);
                            ssg.MySINSearchGroups.Add(ssgFromSIN);
                        }
                        //add all members of his group
                        var members = await sin.MyGroup.GetGroupMembers(_context);

                        foreach (var member in members)
                        {
                            if ((member.SINnerMetaData.Visibility.IsGroupVisible == true) ||
                                (member.SINnerMetaData.Visibility.IsPublic)
                                )
                            {
                                member.MyGroup          = sin.MyGroup;
                                member.MyGroup.MyGroups = new List <SINnerGroup>();
                                SINnerSearchGroupMember sinssgGroupMember = new SINnerSearchGroupMember
                                {
                                    MySINner = member
                                };
                                ssgFromSIN.MyMembers.Add(sinssgGroupMember);
                            }
                        }
                        sin.MyGroup.PasswordHash = "";
                        sin.MyGroup.MyGroups     = new List <SINnerGroup>();
                    }
                }

                ret.SINGroups.Add(ssg);
                return(Ok(ret));
            }
            catch (Exception e)
            {
                if (e is HubException)
                {
                    return(BadRequest(e));
                }
                HubException hue = new HubException(e.Message, e);
                return(BadRequest(hue));
            }
        }
Beispiel #14
0
        private async void TvGroupSearchResult_DragDrop(object sender, DragEventArgs e)
        {
            // Retrieve the client coordinates of the drop location.
            Point targetPoint = tvGroupSearchResult.PointToClient(new Point(e.X, e.Y));

            // Retrieve the node at the drop location.
            TreeNode targetNode = tvGroupSearchResult.GetNodeAt(targetPoint);

            // Retrieve the node that was dragged.
            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

            // Sanity check
            if (draggedNode == null)
            {
                return;
            }
            SINnerSearchGroup draggedGroup = draggedNode.Tag as SINnerSearchGroup;
            SINnerSearchGroup targetGroup  = null;

            // Did the user drop on a valid target node?
            if (targetNode != null)
            {
                targetGroup = targetNode.Tag as SINnerSearchGroup;
            }

            TreeNode parentNode = targetNode;

            // Confirm that the node at the drop location is not
            // the dragged node and that target node isn't null
            // (for example if you drag outside the control)
            if (!draggedNode.Equals(targetNode) /* && targetNode != null*/)
            {
                bool canDrop = true;

                // Crawl our way up from the node we dropped on to find out if
                // if the target node is our parent.
                while (canDrop && (parentNode != null))
                {
                    canDrop    = !Object.ReferenceEquals(draggedNode, parentNode);
                    parentNode = parentNode.Parent;
                }

                // Is this a valid drop location?
                if (canDrop)
                {
                    // Yes. Move the node, expand it, and select it.


                    if (draggedGroup == null)
                    {
                        return;
                    }

                    var client = await StaticUtils.GetClient();

                    var res = await client.PutGroupInGroupWithHttpMessagesAsync(draggedGroup.Id, draggedGroup.Groupname, targetGroup?.Id,
                                                                                draggedGroup.MyAdminIdentityRole, draggedGroup.IsPublic);

                    if (res.Response.StatusCode == HttpStatusCode.OK)
                    {
                        draggedNode.Remove();
                        if (targetNode != null)
                        {
                            targetNode.Nodes.Add(draggedNode);
                            targetNode.Expand();
                        }
                        else
                        {
                            // The user dropped the node on the treeview control instead
                            // of another node so lets place the node at the bottom of the tree.
                            tvGroupSearchResult.Nodes.Add(draggedNode);
                            draggedNode.Expand();
                        }
                    }
                }
            }

            // Optional: Select the dropped node and navigate (however you do it)
            tvGroupSearchResult.SelectedNode = draggedNode;
            // NavigateToContent(draggedNode.Tag);
        }