Ejemplo n.º 1
0
    protected void SaveMemberRole()
    {
        objDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (ip == null)
        {
            ip = Request.ServerVariables["REMOTE_ADDR"];
        }
        objDO.strIpAddress = ip;
        objDO.inGroupId    = Convert.ToInt32(Request.QueryString["GrpId"]);
        objDO.intRoleId    = Convert.ToInt32(ddlRoleDetails.SelectedItem.Value);

        if (Request.QueryString["AccRegId"] != null)
        {
            objDO.inviteMembers = Request.QueryString["AccRegId"];
            objDA.AddEditDel_Scrl_UserGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InsertGroupInvitation);
        }
        else
        {
            objDO.inviteMembers = Request.QueryString["AccGrpOrgRegId"];
            objDA.AddEditDel_Scrl_OrgGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_OrgGroupDetailTbl.InsertGroupInvitation);
        }
    }
    protected void btnSaveGroup_Click(object sender, EventArgs e)
    {
        ViewState["join"] = hdnAutoreqJoin.Value == "1" ? "A" : "R";
        try
        {
            lblSuccMessage.Text = "";
            String GroupeAccess = String.Empty;
            string ip           = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ip == null)
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }

            objgrp.intRegistrationId = Convert.ToInt32(ViewState["UserID"]);
            objgrp.strGroupName      = txtTitle.Text.Trim();
            if (txtPurpose.InnerText != "Description")
            {
                //Defect # 9 HTML Validations
                txtPurpose.InnerText = Validations.validateHtmlInput(txtPurpose.InnerText);
                objgrp.strSummary    = txtPurpose.InnerText.Trim();
            }
            else
            {
                objgrp.strSummary = "";
            }
            objgrp.inGroupId = Convert.ToInt32(ViewState["intGroupId"]);
            string PhotoPath = "";
            if (hdnFileData.Value != "")
            {
                string name = hdnPhotoName.Value;
                string ext  = System.IO.Path.GetExtension(name).ToLower();

                if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
                {
                    lblSuccMess.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                    lblSuccMess.CssClass = "RedErrormsg";
                    return;
                }

                // int FileLength = FileUpload1.PostedFile.ContentLength;
                // if (FileLength <= 3145728)
                // {
                PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(hdnPhotoName.Value).ToString();
                //   FileUpload1.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
                File.WriteAllBytes(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath), Convert.FromBase64String(hdnFileData.Value.Split(',')[1]));
                ViewState["ImagePath"] = PhotoPath;
                Session["ImagePath"]   = PhotoPath;
                ViewState["ImagePath"] = PhotoPath;
                imgUser.Src            = "CroppedPhoto/" + Convert.ToString(Session["ImagePath"]);
                lblSuccMess.Text       = "";
                //}
                // else
                //    PhotoPath = ViewState["ImagePath"].ToString();
            }
            //if (FileUpload1.HasFile)
            //{
            //    string name = FileUpload1.FileName;
            //    string ext = System.IO.Path.GetExtension(name);

            //    if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
            //    {
            //        lblSuccMessage.Text = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
            //        lblSuccMessage.CssClass = "RedErrormsg";
            //        return;
            //    }
            //    int FileLength = FileUpload1.PostedFile.ContentLength;
            //    if (FileLength <= 3145728)
            //    {
            //        PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(FileUpload1.FileName).ToString();
            //        FileUpload1.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
            //        ViewState["ImagePath"] = PhotoPath;
            //        Session["ImagePath"] = PhotoPath;
            //        imgUser.Src = "CroppedPhoto/" + Convert.ToString(Session["ImagePath"]);
            //        ImgRemovePic.Visible = true;
            //        lblSuccMessage.Text = "";
            //    }
            //    else
            //        PhotoPath = Convert.ToString(ViewState["ImagePath"]);
            //}

            if (Session["ImagePath"] != null)
            {
                objgrp.strLogoPath = Session["ImagePath"].ToString();
            }
            else
            {
                objgrp.strLogoPath = "";
            }

            if (Convert.ToString(ViewState["join"]) == "A")
            {
                objgrp.strAccess = Convert.ToString(ViewState["join"]);
            }
            else
            {
                objgrp.strAccess = Convert.ToString(ViewState["join"]);
            }
            objgrp.strIpAddress = ip;
            objgrp.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
            objgrpDB.AddEditDel_Scrl_UserGroupDetailTbl(objgrp, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.Update);
            //Added By Dilip

            WallMessageDO.intAddedBy = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
            WallMessageDO.intGroupId = Convert.ToInt32(ViewState["intGroupId"]);

            List <KeyValuePair <string, string> > members = txtInviteMember.GetSelectedValues();
            // string[] members = totalMembers.Split(',');
            for (int i = 0; i < members.Count; i++)
            {
                if (members[i].Value != "")
                {
                    int IDs = Convert.ToInt32(members[i].Value);
                    objDOgroup.intAddedBy    = Convert.ToInt32(ViewState["UserID"]);
                    objDOgroup.strUniqueKey  = Convert.ToString(ViewState["strUniqueKey"]);
                    objDOgroup.inGroupId     = Convert.ToInt32(ViewState["intGroupId"]);
                    objDOgroup.inviteMembers = Convert.ToString(IDs);

                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.UpGrpRoleRequestPermission);

                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InsertGroupInvitationEdit);


                    int ID = Convert.ToInt32(members[i].Value);
                    WallMessageDO.intInvitedUserId  = Convert.ToInt32(ID);
                    WallMessageDO.striInvitedUserId = Convert.ToString(ID);
                    WallMessageDO.intAddedBy        = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                    WallMessageDO.intGroupId        = Convert.ToInt32(ViewState["intGroupId"]);
                    WallMessageDA.Scrl_AddEditDelWallMessage(WallMessageDO, DA_WallMessage.WallMessage.SelectMessageDetails);

                    if (hdnTitle.Value != objgrp.strGroupName)
                    {
                        WallMessageDO.intAddedBy          = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                        WallMessageDO.intGroupId          = Convert.ToInt32(ViewState["intGroupId"]);
                        WallMessageDO.StrRecommendation   = "Group owner updated the group name as \"" + objgrp.strGroupName + "\"";
                        WallMessageDO.strSubject          = "Group Name Changed";
                        WallMessageDO.strIpAddress        = ip;
                        WallMessageDO.intAddedBy          = Convert.ToInt32(ViewState["UserID"]);
                        WallMessageDO.intInvitedUserId    = Convert.ToInt32(ID);
                        WallMessageDO.striInvitedUserId   = Convert.ToString(ID);
                        WallMessageDO.strTotalGrpMemberID = hdnTitle.Value;
                        WallMessageDA.Scrl_AddEditDelWallMessage(WallMessageDO, DA_WallMessage.WallMessage.Add);
                    }

                    dt = WallMessageDA.GetDataTable(WallMessageDO, DA_WallMessage.WallMessage.CheckMessagesend);
                    if (dt.Rows.Count == 0)
                    {
                        WallMessageDO.intAddedBy = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                        WallMessageDO.intGroupId = Convert.ToInt32(ViewState["intGroupId"]);
                        if (objgrp.strAccess == "A")
                        {
                            WallMessageDO.StrRecommendation = "Group Owner added You to Group.";
                            WallMessageDO.strSubject        = "Group Invitation";
                        }
                        else
                        {
                            WallMessageDO.StrRecommendation = "Group Owner Invite You to Join Group.";
                            WallMessageDO.strSubject        = "Group Invitation";
                        }
                        WallMessageDO.strIpAddress      = ip;
                        WallMessageDO.intAddedBy        = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                        WallMessageDO.intInvitedUserId  = Convert.ToInt32(ID);
                        WallMessageDO.striInvitedUserId = Convert.ToString(ID);

                        WallMessageDA.Scrl_AddEditDelWallMessage(WallMessageDO, DA_WallMessage.WallMessage.Add);
                    }
                    if (objgrp.strAccess == "A")
                    {
                        objGrpJoinDO.inGroupId        = Convert.ToInt32(ViewState["intGroupId"]);
                        objGrpJoinDO.intInvitedUserId = Convert.ToInt32(ViewState["UserID"]);

                        ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                        if (ip == null)
                        {
                            ip = Request.ServerVariables["REMOTE_ADDR"];
                        }
                        objGrpJoinDO.strIpAddress = ip;

                        objGrpJoinDO.intAddedBy        = Convert.ToInt32(ID);
                        objGrpJoinDO.intRegistrationId = Convert.ToInt32(ID);
                        objGrpJoinDO.isAccepted        = 1;
                        objGrpJoinDA.AddEditDel_Scrl_UserGroupJoin(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.Insert);
                    }
                }
            }

            objDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
            if (ip == null)
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }
            objDO.strIpAddress   = ip;
            objDO.inGroupId      = Convert.ToInt32(ViewState["intGroupId"]);
            objDO.strUniqueKey   = objDA.GetUniqueKeyPermissionDataTable(objDO, Convert.ToInt32(ViewState["intGroupId"]));
            objDO.grpInvMemberId = Convert.ToInt32(ViewState["GroupMemberId"]);
            ////commented by akash on 29/04/2015
            //DataTable dttt = objDA.GetDataTable(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.deleteMemeberRole);
            //for (int i = 0; i < members.Length; i++)
            //{
            //    if (members.GetValue(i) != "")
            //    {

            //        lblinviteMemeber.Visible = false;
            //        int ID = Convert.ToInt32(members.GetValue(i));
            //        objDO.strMemberName = ID.ToString();

            //        objDO.inviteMembers = Convert.ToString(ID);
            //        DataTable dt = objDA.GetRolePermissionDataTable(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_GroupModulePermissionTbl.GetinviteMember);
            //        if (dt.Rows.Count > 0)
            //        {
            //            objDO.intModifiedBy = Convert.ToInt32(ViewState["UserID"]);
            //            objDO.intGrpInvitationMemberId = Convert.ToInt32(dt.Rows[0]["intGrpInvitationMemberId"].ToString());
            //            objDA.AddEditDel_Scrl_UserGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.UpdateGroupInvitation);
            //        }
            //        else
            //        {
            //            objDA.AddEditDel_Scrl_UserGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InsertGroupInvitation);
            //        }
            //    }
            //    else
            //    {
            //        lblinviteMemeber.Visible = true;
            //    }
            //}
            ////-----------------------------------
            ViewState["GroupOutId"] = Convert.ToInt32(ViewState["intGroupId"]);
            DataTable dtsub = new DataTable();
            //dtsub = (DataTable)ViewState["SubjectCategory"];
            //if (dtsub.Rows.Count > 0)
            //{
            objgrpDB.AddEditDel_Scrl_UserGroupDetailTbl(objgrp, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.DeleteContextGroupDocument);
            //}
            //else
            //{
            //    objgrpDB.AddEditDel_Scrl_UserGroupDetailTbl(objgrp, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.DeleteContextGroupDocument);
            //}
            List <KeyValuePair <string, string> > contexts = LstSubjCategory.GetSelectedValues();
            foreach (KeyValuePair <string, string> dr in contexts)
            {
                objgrp.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                objgrp.intSubjectCategoryId = Convert.ToInt32(dr.Value);
                objgrp.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                objgrpDB.AddEditDel_Scrl_UserGroupDetailTbl(objgrp, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.UpdateCotextGroupDocument);
            }
            clearGroup();
            divGroupSucces.Style.Add("display", "block");
            Response.Redirect("Group-Profile.aspx?GrpId=" + ViewState["intGroupId"]);
        }
        catch { }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DO_Scrl_UserGroupDetailTbl objDO = new DO_Scrl_UserGroupDetailTbl();
        DA_Scrl_UserGroupDetailTbl objDA = new DA_Scrl_UserGroupDetailTbl();
        String GroupeAccess = String.Empty;

        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (ip == null)
        {
            ip = Request.ServerVariables["REMOTE_ADDR"];
        }

        objDO.intRegistrationId = Convert.ToInt32(ViewState["UserID"]);
        objDO.strGroupName      = txtGroupName.Text.Trim();
        objDO.strSummary        = txtSummary.Text.Trim();
        objDO.strGroupType      = Convert.ToInt32(drpGroupType.SelectedItem.Value);
        objDO.strDescription    = txtDescription.Text;
        objDO.strAccess         = Convert.ToString(RdBList_Access.SelectedItem.Value);
        //It should come from dropdown,time being it is kept as static.
        objDO.locationId = 4;

        if (Convert.ToInt32(RdblistPrivPub.SelectedItem.Value) == 1)
        {
            objDO.bitPrivatePublic = true;
            GroupeAccess           = "PRIVATE";
        }
        else
        {
            objDO.bitPrivatePublic = false;
            GroupeAccess           = "PUBLIC";
        }

        string documentPath = "";

        if (fileupload_LogoPath.HasFile)
        {
            int FileLength = fileupload_LogoPath.PostedFile.ContentLength;
            if (FileLength <= 3145728)
            {
                documentPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(fileupload_LogoPath.FileName).ToString();
                fileupload_LogoPath.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + documentPath));
            }
            else
            {
                documentPath = ViewState["ImagePath"].ToString();
            }
            objDO.strLogoPath = documentPath;
        }

        objDO.strIpAddress = ip;
        if (lblId.Text != "")
        {
            objDO.inGroupId     = Convert.ToInt32(lblId.Text);
            objDO.intModifiedBy = Convert.ToInt32(ViewState["UserID"]);
            objDA.AddEditDel_Scrl_UserGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.Update);
            lblMessage.Text     = "Record updated successfully";
            lblMessage.CssClass = "GreenErrormsg";
            PanlHide();
        }
        else
        {
            objDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
            objDA.AddEditDel_Scrl_UserGroupDetailTbl(objDO, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.Insert);
            lblMessage.Text         = "Record Added successfully";
            lblMessage.CssClass     = "GreenErrormsg";
            ViewState["GroupOutId"] = objDO.GroupOutId;

            string APIURL           = ConfigurationManager.AppSettings["APIURL"];
            string ISAPIURLACCESSED = ConfigurationManager.AppSettings["ISAPIURLACCESSED"];

            if (!string.IsNullOrEmpty(Convert.ToString(ViewState["GroupOutId"])))
            {
                string UserURL = APIURL + "createGroup.action?groupId=" + objDO.GroupOutId + "&groupName=" + objDO.strGroupName + "&scope=PRIVATE&groupParent=Null&groupOwner=" + objDO.intRegistrationId + "";
                try
                {
                    HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL);
                    myRequest1.Method = "GET";
                    WebResponse myResponse1 = myRequest1.GetResponse();

                    StreamReader sr     = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                    String       result = sr.ReadToEnd();

                    objAPILogDO.strURL       = UserURL;
                    objAPILogDO.strAPIType   = "Group";
                    objAPILogDO.strResponse  = result;
                    objAPILogDO.strIPAddress = Request.ServerVariables["REMOTE_ADDR"];
                    objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                }
                catch { }
            }
        }

        ClearControl();
        BindScrl_UserGroupDetailTblList(Convert.ToInt32(ViewState["UserID"]));
    }
Ejemplo n.º 4
0
    protected void btnSaveGroup_Click(object sender, EventArgs e)
    {
        if (hdnAutoreqJoin.Value == "1")
        {
            ViewState["join"] = "A";
        }
        else
        {
            ViewState["join"] = "R";
        }

        // return;
        String GroupeAccess = String.Empty;

        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (ip == null)
        {
            ip = Request.ServerVariables["REMOTE_ADDR"];
        }

        string PhotoPath = "";

        if (FileUpload1.HasFile)
        {
            string name = FileUpload1.FileName;
            string ext  = System.IO.Path.GetExtension(name);

            if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
            {
                lblSuccMess.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                lblSuccMess.CssClass = "RedErrormsg";
                return;
            }

            int FileLength = FileUpload1.PostedFile.ContentLength;
            if (FileLength <= 3145728)
            {
                PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(FileUpload1.FileName).ToString();
                FileUpload1.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
                ViewState["ImagePath"] = PhotoPath;
                lblSuccMess.Text       = "";
            }
            else
            {
                PhotoPath = ViewState["ImagePath"].ToString();
            }
        }

        if (ViewState["ImagePath"] != null)
        {
            objDOgroup.strLogoPath = PhotoPath.ToString();
        }

        objDOgroup.intRegistrationId = Convert.ToInt32(ViewState["UserID"]);
        objDOgroup.strGroupName      = txtCreateGr.Text.Trim();
        ViewState["strGroupName"]    = txtCreateGr.Text.Trim();
        if (txtPurpose.InnerText.Trim() != "Description")
        {
            objDOgroup.strSummary = txtPurpose.InnerText.Trim();
        }
        else
        {
            objDOgroup.strSummary = "";
        }

        objDOgroup.strUniqueKey = ViewState["ukey"].ToString();
        if (ViewState["join"].ToString() == "A")
        {
            objDOgroup.strAccess = Convert.ToString(ViewState["join"]);
        }
        else
        {
            objDOgroup.strAccess = Convert.ToString(ViewState["join"]);
        }
        objDOgroup.strInvitationMessage = "";


        objDOgroup.strIpAddress = ip;

        objDOgroup.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
        objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.Insert);
        ViewState["GroupOutId"] = objDOgroup.GroupOutId;

        objDOgroup.strIpAddress = ip;
        string totalMembers = hdnMembId.Value;

        objDOgroup.strUniqueKey = ViewState["ukey"].ToString();

        if (hdnSubject.Value != "")
        {
            string[] totalSubjects = hdnSubject.Value.Split(',');
            var      dictionary    = new Dictionary <int, int>();

            Dictionary <string, int> counts = totalSubjects.GroupBy(x => x)
                                              .ToDictionary(g => g.Key,
                                                            g => g.Count());

            foreach (var v in counts)
            {
                if (v.Value == 1)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 3)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 5)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 7)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 9)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
            }
        }

        string[] members = totalMembers.Split(',');
        for (int i = 0; i < members.Length; i++)
        {
            if (Convert.ToString(members.GetValue(i)) != "")
            {
                int IDs = Convert.ToInt32(members.GetValue(i));
                objDOgroup.inGroupId     = Convert.ToInt32(ViewState["GroupOutId"]);
                objDOgroup.inviteMembers = Convert.ToString(IDs);
                objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InsertGroupInvitation);

                if (ViewState["join"].ToString() == "A")
                {
                    objGrpJoinDO.inGroupId        = Convert.ToInt32(ViewState["GroupOutId"]);
                    objGrpJoinDO.intInvitedUserId = Convert.ToInt32(ViewState["UserID"]);

                    ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (ip == null)
                    {
                        ip = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objGrpJoinDO.strIpAddress = ip;

                    objGrpJoinDO.intAddedBy        = Convert.ToInt32(IDs);
                    objGrpJoinDO.intRegistrationId = Convert.ToInt32(IDs);
                    objGrpJoinDO.isAccepted        = 1;
                    objGrpJoinDA.AddEditDel_Scrl_UserGroupJoin(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.Insert);
                }
            }
        }

        for (int i = 0; i < members.Length; i++)
        {
            if (Convert.ToString(members.GetValue(i)) != "")
            {
                int IDs = Convert.ToInt32(members.GetValue(i));
                WallMessageDO.intAddedBy = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                WallMessageDO.intGroupId = Convert.ToInt32(ViewState["GroupOutId"]);
                if (ViewState["join"].ToString() == "A")
                {
                    WallMessageDO.StrRecommendation = "Group Owner added You to Group.";
                }
                else
                {
                    WallMessageDO.StrRecommendation = "Group Owner Invite You to Join Group.";
                }
                WallMessageDO.strIpAddress        = ip;
                WallMessageDO.intAddedBy          = Convert.ToInt32(ViewState["UserID"]);
                WallMessageDO.intInvitedUserId    = Convert.ToInt32(IDs);
                WallMessageDO.striInvitedUserId   = Convert.ToString(IDs);
                WallMessageDO.strSubject          = "Group Invitation";
                WallMessageDO.strTotalGrpMemberID = txtCreateGr.Text.Trim();
                WallMessageDA.Scrl_AddEditDelWallMessage(WallMessageDO, DA_WallMessage.WallMessage.Add);
            }
        }

        getInviteeName();
        string ID = "ctl00$ContentPlaceHolder1$lnkCreateGroup";

        hdnTabId.Value = ID;

        if (ISAPIURLACCESSED != "0")
        {
            if (!string.IsNullOrEmpty(Convert.ToString(ViewState["GroupOutId"])))
            {
                string UserURL = APIURL + "createGroup.action?groupId=" + objDOgroup.inGroupId +
                                 "&groupName=" + objDOgroup.strGroupName +
                                 "&scope=PRIVATE&groupParent=Null&groupOwner=" + objDOgroup.intRegistrationId +
                                 "&groupCreationDate=" + DateTime.Now.ToString();
                try
                {
                    HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL);
                    myRequest1.Method = "GET";
                    if (ISAPIResponse != "0")
                    {
                        WebResponse  myResponse1 = myRequest1.GetResponse();
                        StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result      = sr.ReadToEnd();

                        objAPILogDO.strURL       = UserURL;
                        objAPILogDO.strAPIType   = "Group";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = Request.ServerVariables["REMOTE_ADDR"];
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }


                    UserURL = APIURL + "addMemberToGroup.action?" +
                              "groupId=GRP" + Request.QueryString["GrpId"] +
                              "&members=" + totalMembers;

                    HttpWebRequest myRequest11 = (HttpWebRequest)WebRequest.Create(UserURL);
                    myRequest11.Method = "GET";
                    if (ISAPIResponse != "0")
                    {
                        WebResponse myResponse11 = myRequest1.GetResponse();

                        StreamReader sr1     = new StreamReader(myResponse11.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result1 = sr1.ReadToEnd();

                        objAPILogDO.strURL       = UserURL;
                        objAPILogDO.strAPIType   = "Group Member";
                        objAPILogDO.strResponse  = result1;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDO.strIPAddress = objGrpJoinDO.strIpAddress;
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }
                }
                catch { }
            }
        }
        clearGroup();
        divDeletesucess.Style.Add("display", "block");
    }
    protected void btnSaveGroup_Click(object sender, EventArgs e)
    {
        if (hdnAutoreqJoin.Value == "1")
        {
            ViewState["join"] = "A";
        }
        else
        {
            ViewState["join"] = "R";
        }

        // return;
        String GroupeAccess = String.Empty;

        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (ip == null)
        {
            ip = Request.ServerVariables["REMOTE_ADDR"];
        }

        string PhotoPath = "";

        if (hdnFileData.Value != "")
        {
            string name = hdnPhotoName.Value;
            string ext  = System.IO.Path.GetExtension(name);

            if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
            {
                lblSuccMess.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                lblSuccMess.CssClass = "RedErrormsg";
                return;
            }

            // int FileLength = FileUpload1.PostedFile.ContentLength;
            // if (FileLength <= 3145728)
            // {
            PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(hdnPhotoName.Value).ToString();
            //   FileUpload1.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
            File.WriteAllBytes(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath), Convert.FromBase64String(hdnFileData.Value.Split(',')[1]));
            ViewState["ImagePath"] = PhotoPath;
            lblSuccMess.Text       = "";
            //}
            // else
            //    PhotoPath = ViewState["ImagePath"].ToString();
        }

        if (ViewState["ImagePath"] != null)
        {
            objDOgroup.strLogoPath = PhotoPath.ToString();
        }

        objDOgroup.intRegistrationId = Convert.ToInt32(ViewState["UserID"]);
        //Defect # 9 HTML Validations
        txtCreateGr.Text          = Validations.validateHtmlInput(txtCreateGr.Text);
        objDOgroup.strGroupName   = txtCreateGr.Text.Trim();
        ViewState["strGroupName"] = txtCreateGr.Text.Trim();
        if (txtPurpose.InnerText.Trim() != "Description")
        {
            //Defect # 9 HTML Validations

            objDOgroup.strSummary = Validations.validateHtmlInput(txtPurpose.InnerText.Trim());
        }
        else
        {
            objDOgroup.strSummary = "";
        }

        objDOgroup.strUniqueKey = ViewState["ukey"].ToString();
        if (ViewState["join"].ToString() == "A")
        {
            objDOgroup.strAccess = Convert.ToString(ViewState["join"]);
        }
        else
        {
            objDOgroup.strAccess = Convert.ToString(ViewState["join"]);
        }
        objDOgroup.strInvitationMessage = "";


        objDOgroup.strIpAddress = ip;

        objDOgroup.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
        objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.Insert);
        ViewState["GroupOutId"] = objDOgroup.GroupOutId;

        objDOgroup.strIpAddress = ip;
        List <KeyValuePair <string, string> > members = txtInviteMember.GetSelectedValues();

        //  string totalMembers = hdnMembId.Value;
        objDOgroup.strUniqueKey = ViewState["ukey"].ToString();
        List <KeyValuePair <string, string> > subJectValues = lstCreateGroup.GetSelectedValues();


        if (subJectValues != null && subJectValues.Count > 0)
        {
            string[] subJectCateValues = subJectValues.Select(s => (string)s.Value).ToArray();
            var      dictionary        = new Dictionary <int, int>();

            Dictionary <string, int> counts = subJectCateValues.ToArray().GroupBy(x => x)
                                              .ToDictionary(g => g.Key,
                                                            g => g.Count());

            foreach (var v in counts)
            {
                if (v.Value == 1)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 3)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 5)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 7)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
                else if (v.Value == 9)
                {
                    objDOgroup.inGroupId            = Convert.ToInt32(ViewState["GroupOutId"]);
                    objDOgroup.intSubjectCategoryId = Convert.ToInt32(v.Key);
                    objDOgroup.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                    objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InserCotextOrgGroupDocument);
                }
            }
        }

        //  string[] members = totalMembers.Split(',');
        for (int i = 0; i < members.Count; i++)
        {
            if (Convert.ToString(members[i].Value) != "")
            {
                int IDs = Convert.ToInt32(members[i].Value);
                objDOgroup.inGroupId     = Convert.ToInt32(ViewState["GroupOutId"]);
                objDOgroup.inviteMembers = Convert.ToString(IDs);
                objDAgroup.AddEditDel_Scrl_UserGroupDetailTbl(objDOgroup, DA_Scrl_UserGroupDetailTbl.Scrl_UserGroupDetailTbl.InsertGroupInvitation);

                if (ViewState["join"].ToString() == "A")
                {
                    objGrpJoinDO.inGroupId        = Convert.ToInt32(ViewState["GroupOutId"]);
                    objGrpJoinDO.intInvitedUserId = Convert.ToInt32(ViewState["UserID"]);

                    ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (ip == null)
                    {
                        ip = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objGrpJoinDO.strIpAddress = ip;

                    objGrpJoinDO.intAddedBy        = Convert.ToInt32(IDs);
                    objGrpJoinDO.intRegistrationId = Convert.ToInt32(IDs);
                    objGrpJoinDO.isAccepted        = 1;
                    objGrpJoinDA.AddEditDel_Scrl_UserGroupJoin(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.Insert);
                }
            }
        }

        for (int i = 0; i < members.Count; i++)
        {
            if (Convert.ToString(members[i].Value) != "")
            {
                int IDs = Convert.ToInt32(members[i].Value);
                WallMessageDO.intAddedBy = Convert.ToInt32(Convert.ToString(Session["ExternalUserId"]));
                WallMessageDO.intGroupId = Convert.ToInt32(ViewState["GroupOutId"]);
                if (ViewState["join"].ToString() == "A")
                {
                    WallMessageDO.StrRecommendation = "Group Owner added You to Group.";
                    //SendMailGroup(); //IDs, Convert.ToInt32(ViewState["UserID"])
                }
                else
                {
                    WallMessageDO.StrRecommendation = "Group Owner Invite You to Join Group.";
                    //SendMailGroup();
                }
                WallMessageDO.strIpAddress      = ip;
                WallMessageDO.intAddedBy        = Convert.ToInt32(ViewState["UserID"]);
                WallMessageDO.intInvitedUserId  = Convert.ToInt32(IDs);
                WallMessageDO.striInvitedUserId = Convert.ToString(IDs);
                WallMessageDO.strSubject        = "Group Invitation";
                //Defect # 9 HTML Validations
                WallMessageDO.strTotalGrpMemberID = Validations.validateHtmlInput(txtCreateGr.Text.Trim());
                WallMessageDA.Scrl_AddEditDelWallMessage(WallMessageDO, DA_WallMessage.WallMessage.Add);
            }
        }

        getInviteeName();
        string ID = "lnkCreateGroup";

        hdnTabId.Value = ID;

        if (ISAPIURLACCESSED != "0")
        {
            if (!string.IsNullOrEmpty(Convert.ToString(ViewState["GroupOutId"])))
            {
                StringBuilder UserURL = new StringBuilder();
                UserURL.Append(APIURL);
                UserURL.Append("createGroup.action?groupId=");
                UserURL.Append(objDOgroup.inGroupId);
                UserURL.Append("&groupName=");
                UserURL.Append(objDOgroup.strGroupName);
                UserURL.Append("&scope=PRIVATE&groupParent=Null&groupOwner=");
                UserURL.Append(objDOgroup.intRegistrationId);
                UserURL.Append("&groupCreationDate=");
                UserURL.Append(DateTime.Now.ToString());


                try
                {
                    HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL.ToString());
                    myRequest1.Method = "GET";
                    if (ISAPIResponse != "0")
                    {
                        WebResponse  myResponse1 = myRequest1.GetResponse();
                        StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result      = sr.ReadToEnd();

                        objAPILogDO.strURL       = UserURL.ToString();
                        objAPILogDO.strAPIType   = "Group";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = Request.ServerVariables["REMOTE_ADDR"];
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }
                    string[] ttlMembers = null;
                    ttlMembers = (from item in members select item.Value).ToArray();
                    string totalMembers = String.Join(",", ttlMembers);

                    UserURL = new StringBuilder();
                    UserURL.Append(APIURL);
                    UserURL.Append("addMemberToGroup.action?");
                    UserURL.Append("groupId=GRP");
                    UserURL.Append(Request.QueryString["GrpId"]);
                    UserURL.Append("&members=");
                    UserURL.Append(totalMembers);

                    HttpWebRequest myRequest11 = (HttpWebRequest)WebRequest.Create(UserURL.ToString());
                    myRequest11.Method = "GET";
                    if (ISAPIResponse != "0")
                    {
                        WebResponse myResponse11 = myRequest1.GetResponse();

                        StreamReader sr1     = new StreamReader(myResponse11.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result1 = sr1.ReadToEnd();

                        objAPILogDO.strURL       = UserURL.ToString();
                        objAPILogDO.strAPIType   = "Group Member";
                        objAPILogDO.strResponse  = result1;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDO.strIPAddress = objGrpJoinDO.strIpAddress;
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }
                }
                catch { }
            }
        }
        //SendMailGroup();
        clearGroup();
        // ScriptManager.RegisterStartupScript(this, this.GetType(), "s", "showSuccessPopup('Alert','Group created sucessfully.');", true);

        divDeletesucess.Style.Add("display", "block");
    }