Exemplo n.º 1
0
    protected void lnkConnDisconn_Click(object sender, EventArgs e)
    {
        divConnDisPopup.Style.Add("display", "none");
        string name = "", emailId = "";
        int    accept        = 0;
        int    InvitedUserId = Convert.ToInt32(ViewState["RegId"]);

        objdoreg.InvitedUserId  = Convert.ToInt32(ViewState["RegId"]);
        objdoreg.RegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());

        if (Convert.ToString(Session["ExternalUserId"]) != "" && Session["ExternalUserId"] != null)
        {
            objdoreg.RegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
            objdoreg.InvitedUserId  = Convert.ToInt32(ViewState["RegId"]);
            DataTable dtReq = new DataTable();
            dtReq = objdareg.GetExistsRequest(objdoreg, DA_Registrationdetails.RegistrationDetails.SingleRecord);
            if (dtReq.Rows.Count > 0)
            {
                name    = Convert.ToString(dtReq.Rows[0]["Name"]);
                emailId = Convert.ToString(dtReq.Rows[0]["vchrUserName"]);
                accept  = Convert.ToInt32(dtReq.Rows[0]["IsAccepted"]);

                if (Convert.ToInt32(dtReq.Rows[0]["IsAccepted"]) == 0)
                {
                    if (Convert.ToInt32(dtReq.Rows[0]["Accepts"]) != 2)
                    {
                        divConnDisPopup.Style.Add("display", "none");
                        divSuccess.Style.Add("display", "block");
                        lblSuccess.Text      = "You have already send the request.";
                        lblSuccess.ForeColor = System.Drawing.Color.Red;
                        divSuccess.Style.Add("display", "block");
                        return;
                    }
                    else
                    {
                        objdoreg.intRequestInvitaionId = Convert.ToInt32(dtReq.Rows[0]["intRequestInvitaionId"]);
                        objdareg.AddEditDel_Request(objdoreg, DA_Registrationdetails.RegistrationDetails.Update);
                        divConnDisPopup.Style.Add("display", "none");
                        BinduserSearch();
                        return;
                    }
                }
            }
        }
        else
        {
            return;
        }
        objdoreg.ConnectRegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
        objdoreg.AddedBy   = Convert.ToInt32(Session["ExternalUserId"].ToString());
        objdoreg.IpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (objdoreg.IpAddress == null)
        {
            objdoreg.IpAddress = Request.ServerVariables["REMOTE_ADDR"];
        }

        if (Convert.ToString(ViewState["CommandName"]).Trim() == "DisConnect")
        {
            objdareg.AddEditDel_Request(objdoreg, DA_Registrationdetails.RegistrationDetails.UpdateConnection);

            if (ISAPIURLACCESSED == "1")
            {
                try
                {
                    String url = APIURL + "disconnectUser.action?" +
                                 "uidFirstUser="******"&uidSecondUser="******"GET";
                    if (ISAPIResponse == "1")
                    {
                        WebResponse  myResponse1 = myRequest1.GetResponse();
                        StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result      = sr.ReadToEnd();
                        objAPILogDO.strURL       = url;
                        objAPILogDO.strAPIType   = "Search People Disconnect User";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = objdoreg.IpAddress;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }
                }
                catch { }
            }

            if (Convert.ToString(ViewState["ViewAll"]) == "1")
            {
                BindSingleData();
            }
            else
            {
                BinduserSearch();
            }
            lblSuccess.Text      = "Successfully removed from the friendlist.";
            lblSuccess.ForeColor = System.Drawing.Color.Green;
            divSuccess.Style.Add("display", "block");
            return;
        }
        else
        {
            objdareg.AddEditDel_Request(objdoreg, DA_Registrationdetails.RegistrationDetails.Add);

            objdoreg.RegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
            objdoreg.InvitedUserId  = Convert.ToInt32(ViewState["RegId"]);
            DataTable dtReqs = new DataTable();
            dtReqs = objdareg.GetExistsRequest(objdoreg, DA_Registrationdetails.RegistrationDetails.SingleRecord);
            if (dtReqs.Rows.Count > 0)
            {
                name    = Convert.ToString(dtReqs.Rows[0]["Name"]);
                emailId = Convert.ToString(dtReqs.Rows[0]["vchrUserName"]);
                accept  = Convert.ToInt32(dtReqs.Rows[0]["IsAccepted"]);
            }

            if (ISAPIURLACCESSED == "1")
            {
                try
                {
                    String url = APIURL + "connectUser.action?" +
                                 "uidFirstUser="******"&uidSecondUser="******"GET";
                    if (ISAPIResponse == "1")
                    {
                        WebResponse  myResponse1 = myRequest1.GetResponse();
                        StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result      = sr.ReadToEnd();
                        objAPILogDO.strURL       = url;
                        objAPILogDO.strAPIType   = "Search People Connect User";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = objdoreg.IpAddress;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                    }
                }
                catch { }
            }
            if (Convert.ToString(ViewState["ViewAll"]) == "1")
            {
                BindSingleData();
            }
            else
            {
                BinduserSearch();
            }
            SendMailConnections(emailId, name, accept);
            lblSuccess.Text      = "Request Invitation and a mail has been send to the person.";
            lblSuccess.ForeColor = System.Drawing.Color.Green;
        }
        divConnDisPopup.Style.Add("display", "none");
        divSuccess.Style.Add("display", "block");
    }
Exemplo n.º 2
0
    protected void GetUserEmailId()
    {
        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        dt = new DataTable();
        objLogin.intRegistartionID = Convert.ToInt32(ViewState["RegOutId"]);
        dt = objLoginDB.GetDataTable(objLogin, DA_SKORKEL.DA_Login.Login_1.UserDetails);

        if (dt.Rows.Count > 0)
        {
            UserSession.UserInfo UInfo = new UserSession.UserInfo();
            string LoginName           = Convert.ToString(dt.Rows[0]["LoginName"]);
            UInfo.UserName = Convert.ToString(dt.Rows[0]["vchrUserName"]);
            UInfo.UserID   = Convert.ToInt64(dt.Rows[0]["intRegistrationId"]);
            int TypeId = Convert.ToInt32(dt.Rows[0]["intUserTypeID"]);

            if (ISAPIURLACCESSED == "1")
            {
                StringBuilder UserURL = new StringBuilder();
                UserURL.Append(APIURL);
                UserURL.Append("registerUser.action?");
                UserURL.Append("uid=");
                UserURL.Append(Convert.ToString(dt.Rows[0]["intRegistrationId"]));
                UserURL.Append("&userId=");
                UserURL.Append(Convert.ToString(dt.Rows[0]["vchrUserName"]));
                UserURL.Append("&password="******"vchrPassword"]));
                UserURL.Append("&firstName=");
                UserURL.Append(Convert.ToString(dt.Rows[0]["vchrFirstName"]));
                UserURL.Append("&lastName=");
                UserURL.Append(Convert.ToString(dt.Rows[0]["vchrLastName"]));
                UserURL.Append("&userType=STUDENT");
                UserURL.Append("&userContextIds=" + null);
                UserURL.Append("&friendUserIds=" + null);
                UserURL.Append("&lawRelated=" + null);

                try
                {
                    HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL.ToString());
                    myRequest1.Method = "GET";
                    WebResponse myResponse1 = myRequest1.GetResponse();

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

                    objAPILogDO.strURL      = UserURL.ToString();
                    objAPILogDO.strAPIType  = "Student";
                    objAPILogDO.strResponse = result;

                    if (ip == null)
                    {
                        objAPILogDO.strIPAddress = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                }
                catch (Exception ex)
                { ex.Message.ToString(); }
            }
            Session.Add("UserTypeId", TypeId);
            Session.Add("UInfo", UInfo);
            Session.Add("LoginName", LoginName);
            Session.Add("ExternalUserId", Convert.ToString(dt.Rows[0]["intRegistrationId"]));
            Response.Redirect("Home.aspx");
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string docPath = "";

        if (Session["SubmitTime"].ToString() == ViewState["SubmitTime"].ToString())
        {
            if (CKDescription.InnerText != "Write your question here...")
            {
                if (CKDescription.InnerText.Trim() != "")
                {
                    if (uploadDoc.HasFile)
                    {
                        int    FileLength = uploadDoc.PostedFile.ContentLength;
                        string ext        = System.IO.Path.GetExtension(this.uploadDoc.PostedFile.FileName);

                        if (FileLength <= 3145728)
                        {
                            docPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(uploadDoc.FileName).ToString();
                            uploadDoc.SaveAs(Server.MapPath("~\\UploadQuetionAns\\" + docPath));
                            ViewState["docPath"]       = docPath;
                            objDOQAPosting.strFilePath = docPath;
                            objDOQAPosting.strFileName = uploadDoc.FileName;
                        }
                        else
                        {
                            lblMessage.Text     = "File size should be less than or equal to 3MB";
                            lblMessage.CssClass = "RedErrormsg";
                            return;
                        }
                    }
                    string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (ip == null)
                    {
                        ip = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objDOQAPosting.strIPAddress = ip;

                    if (ViewState["PostQAId"] == null)
                    {
                        //string editor = CKDescription.InnerText.Trim().Replace(",", "''");
                        string editor = CKDescription.InnerText.Trim();
                        string noHTML = Regex.Replace(editor, @"<[^>]+>|&nbsp;", "").Trim();
                        objDOQAPosting.strQuestionDescription = Regex.Replace(noHTML, @"\s{2,}", " ");
                        objDOQAPosting.intAddedBy             = Convert.ToInt32(ViewState["UserID"]);
                        objDAQAPosting.AddEditDel_Scrl_UserQueAnsPostingTbl(objDOQAPosting, DA_Scrl_UserQAPosting.QuetionAns.Add);
                        ViewState["QueAnsId"] = objDOQAPosting.intPostQuestionId;
                        List <KeyValuePair <string, string> > subJectValues = txtSubjectList.GetSelectedValues();
                        // string totalMembers = hdnsubject.Value;
                        if (subJectValues != null && subJectValues.Count > 0)
                        {
                            string[] members = subJectValues.Select(s => (string)s.Value).ToArray();

                            for (int i = 0; i < members.Length; i++)
                            {
                                if (Convert.ToString(members.GetValue(i)) != "")
                                {
                                    int ID = Convert.ToInt32(members.GetValue(i));
                                    objDOQAPosting.intPostQuestionId    = Convert.ToInt32(ViewState["QueAnsId"]);
                                    objDOQAPosting.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                                    objDOQAPosting.intSubjectCategoryId = ID;
                                    objDAQAPosting.AddEditDel_Scrl_UserQueAnsPostingTbl(objDOQAPosting, DA_Scrl_UserQAPosting.QuetionAns.ADDSelectedSubCatId);
                                }
                            }
                        }

                        //                if (ISAPIURLACCESSED != "0")
                        //                {
                        //                    try
                        //                    {
                        //StringBuilder url = new StringBuilder();
                        //url.Append(APIURL);
                        //url.Append("addQuestion.action?");
                        //url.Append("questionId");
                        //url.Append(objDOQAPosting.intPostQuestionId);
                        //url.Append("&userId=" +null);
                        //url.Append(objDOQAPosting.intAddedBy);
                        //url.Append("&userName="******"&insertDt =");
                        //url.Append(DateTime.Now);
                        //url.Append("&content=");
                        //url.Append(objDOQAPosting.strQuestionDescription);
                        //url.Append("&title =");
                        //url.Append(objDOQAPosting.strQuestionDescription);
                        //                        HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                        //                        myRequest1.Method = "GET";
                        //                        WebResponse myResponse1 = myRequest1.GetResponse();
                        //                        StreamReader sr = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        //                        String result = sr.ReadToEnd();
                        //                        objAPILogDO.strURL = url.ToString();
                        //                        objAPILogDO.strAPIType = "Post Question";
                        //                        objAPILogDO.strResponse = result;
                        //                        objAPILogDO.strIPAddress = ip;
                        //                        objAPILogDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
                        //                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                        //                    }
                        //                    catch { }
                        //                }

                        if (ISAPIURLACCESSED != "0")
                        {
                            try
                            {
                                StringBuilder url = new StringBuilder();
                                url.Append(APIURL);
                                url.Append("addQuestion?");
                                url.Append("questionId=");
                                url.Append(ViewState["QueAnsId"]);
                                url.Append("&content=");
                                url.Append(objDOQAPosting.strQuestionDescription);
                                url.Append("&userName="******"&userId=");
                                url.Append(objDOQAPosting.intAddedBy);
                                url.Append("&title=");
                                url.Append("question");

                                HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                                myRequest1.Method = "GET";
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();

                                objAPILogDO.strURL       = url.ToString();
                                objAPILogDO.strAPIType   = "Add Question";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.strIPAddress = ip;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                            catch { }
                        }

                        hdnsubject.Value        = "";
                        CKDescription.InnerText = "";
                        lblSuMess.Text          = "";
                        GetRelatedQuestion();
                        Session["SubmitTime"] = DateTime.Now.ToString();
                        divSuccess.Visible    = true;
                        divSuccess.Style.Add("display", "block");
                        //lblSuccess.Text = "Question Created successfully.";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg1", "CallPostimgs(),callClose(),CallOnRequestSucess();", true);
                    }
                    else
                    {
                        //string editor = CKDescription.InnerText.Trim().Replace(",", "''");
                        string editor = CKDescription.InnerText.Trim();
                        string noHTML = Regex.Replace(editor, @"<[^>]+>|&nbsp;", "").Trim();
                        objDOQAPosting.strQuestionDescription = Regex.Replace(noHTML, @"\s{2,}", " ");
                        objDOQAPosting.intPostQuestionId      = Convert.ToInt32(ViewState["PostQAId"]);
                        objDOQAPosting.intAddedBy             = Convert.ToInt32(ViewState["UserID"]);
                        objDAQAPosting.AddEditDel_Scrl_UserQueAnsPostingTbl(objDOQAPosting, DA_Scrl_UserQAPosting.QuetionAns.Update);

                        if (!string.IsNullOrEmpty(Convert.ToString(ViewState["SubjectCategory"])))
                        {
                            objDOQAPosting.intPostQuestionId = Convert.ToInt32(ViewState["PostQAId"]);
                            objDAQAPosting.AddEditDel_Scrl_UserQueAnsPostingTbl(objDOQAPosting, DA_Scrl_UserQAPosting.QuetionAns.DeleteSelectedSubCatId);
                            List <KeyValuePair <string, string> > subJectValues = txtSubjectList.GetSelectedValues();
                            if (subJectValues != null && subJectValues.Count > 0)
                            {
                                //  string totalMembers = hdnsubject.Value;
                                string[] members = subJectValues.Select(s => (string)s.Value).ToArray();
                                for (int i = 0; i < members.Length; i++)
                                {
                                    if (Convert.ToString(members.GetValue(i)) != "")
                                    {
                                        int ID = Convert.ToInt32(members.GetValue(i));
                                        objDOQAPosting.intPostQuestionId    = Convert.ToInt32(ViewState["PostQAId"]);
                                        objDOQAPosting.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                                        objDOQAPosting.intSubjectCategoryId = ID;
                                        objDAQAPosting.AddEditDel_Scrl_UserQueAnsPostingTbl(objDOQAPosting, DA_Scrl_UserQAPosting.QuetionAns.ADDSelectedSubCatId);
                                    }
                                }
                            }
                        }

                        //                if (ISAPIURLACCESSED != "0")
                        //                {
                        //                    try
                        //                    {
                        //StringBuilder url = new StringBuilder();
                        //url.Append(APIURL);
                        //url.Append("addQuestion.action?");
                        //url.Append("questionId=");
                        //url.Append(objDOQAPosting.intPostQuestionId);
                        //url.Append("&userId=");
                        //url.Append(objDOQAPosting.intAddedBy);
                        //url.Append("&userName="******"&insertDt=");
                        //url.Append(DateTime.Now);
                        //url.Append("&content=");
                        //url.Append(objDOQAPosting.strQuestionDescription);
                        //url.Append("&title =");
                        //url.Append(objDOQAPosting.strQuestionDescription);


                        //                        HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                        //                        myRequest1.Method = "GET";
                        //                        WebResponse myResponse1 = myRequest1.GetResponse();
                        //                        StreamReader sr = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        //                        String result = sr.ReadToEnd();
                        //                        objAPILogDO.strURL = url.ToString();
                        //                        objAPILogDO.strAPIType = "Post Question";
                        //                        objAPILogDO.strResponse = result;
                        //                        objAPILogDO.strIPAddress = ip;
                        //                        objAPILogDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
                        //                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                        //                    }
                        //                    catch { }
                        //                }

                        if (ISAPIURLACCESSED != "0")
                        {
                            try
                            {
                                StringBuilder url = new StringBuilder();
                                url.Append(APIURL);
                                url.Append("updateQuestion?");
                                url.Append("questionId=");
                                url.Append(Convert.ToString(ViewState["PostQAId"]));
                                url.Append("&content=");
                                url.Append(objDOQAPosting.strQuestionDescription);
                                url.Append("&userName="******"&userId=");
                                url.Append(objDOQAPosting.intAddedBy);
                                url.Append("&title=");
                                url.Append("question");

                                HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                                myRequest1.Method = "GET";
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();

                                objAPILogDO.strURL       = url.ToString();
                                objAPILogDO.strAPIType   = "Update Question";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.strIPAddress = ip;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                            catch { }
                        }

                        hdnsubject.Value        = "";
                        CKDescription.InnerText = "";
                        lblSuMess.Text          = "";
                        hdnsubject.Value        = "";
                        GetRelatedQuestion();
                        SubjectTempDataTable();
                        Session["SubmitTime"] = DateTime.Now.ToString();
                        //lblSuccess.Text = "Question Updated Successfully.";
                        divSuccess.Visible = true;
                        divSuccess.Style.Add("display", "block");
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg1", "CallPostimgs(),callClose(),CallOnRequestSucess();", true);
                    }
                    ViewState["PostQAId"] = null;
                }
                else
                {
                    lblSuMess.Text      = "Please add question";
                    lblSuMess.ForeColor = System.Drawing.Color.Red;
                    divSuccess.Style.Add("display", "none");
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg3", "CallPostimgs();", true);
                }
            }
            else
            {
                lblSuMess.Text      = "Please add question";
                lblSuMess.ForeColor = System.Drawing.Color.Red;
                divSuccess.Style.Add("display", "none");
                ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg4", "CallPostimgs();", true);
            }
        }
    }
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        divSuccessEvent.Style.Add("display", "none");
        lblDateMessage1.Text = "";
        lbleventColor.Text   = "";
        lblDateMessage.Text  = "";
        TextBox1.Style.Add("background-color", txtColorCode.Text);
        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (ip == null)
        {
            ip = Request.ServerVariables["REMOTE_ADDR"];
        }
        if (string.IsNullOrEmpty(Convert.ToString(hdnUpdateEventId.Value)))
        {
            if (string.IsNullOrEmpty(txtToDate.Text) || string.IsNullOrEmpty(txtFromDate.Text))
            {
                lblDateMessage1.Style.Add("display", "block");
                lblDateMessage1.Text = "Please select date";
                return;
            }
            if (Convert.ToDateTime(txtFromDate.Text) < DateTime.Today)
            {
                lblDateMessage1.Style.Add("display", "block");
                lblDateMessage1.Text = "From date should be equal to or greater than today's date";
                return;
            }
            else if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
            {
                lblDateMessage1.Style.Add("display", "block");
                lblDateMessage1.Text = "To date should be equal to or greater than from date";
                return;
            }
        }
        else
        {
            if (Convert.ToDateTime(txtToDate.Text) < DateTime.Today)
            {
                lblDateMessage1.Style.Add("display", "block");
                lblDateMessage1.Text = "To date should be equal to or greater than today's date";
                return;
            }
            else if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
            {
                lblDateMessage1.Style.Add("display", "block");
                lblDateMessage1.Text = "To date should be equal to or greater than from date";
                return;
            }
        }

        if (ddlPriorityType.SelectedItem.Value == "S")
        {
            lblDateMessage.Style.Add("display", "block");
            lblDateMessage.Text = "Select event priority.";
            return;
        }

        if (txtColorCode.Text == "")
        {
            lbleventColor.Style.Add("display", "block");
            lbleventColor.Text = "Select event color.";
            return;
        }

        objDO.intGroupId = Convert.ToInt32(ViewState["intGroupId"]);
        objDO.strTitle   = txtTitle.Text.Trim().Replace("'", "''");
        if (txtDescription.InnerText.Trim() == "Description")
        {
            objDO.strDescription = "";
        }
        else
        {
            objDO.strDescription = txtDescription.InnerText.Trim().Replace("'", "''");
        }
        objDO.intAddedBy  = Convert.ToInt32(ViewState["UserID"]);
        objDO.strLocation = txtVenue.Text.Trim().Replace("'", "''");;
        objDO.strColor    = txtColorCode.Text.Trim().Replace("'", "''");

        if (txtFromDate.Text.Trim() != "" && txtFromDate.Text.Trim() != null)
        {
            objDO.dtFromDate = Convert.ToDateTime(txtFromDate.Text.Trim().Replace("'", "''"));
        }
        else
        {
            return;
        }
        objDO.dtTodate = Convert.ToDateTime(txtToDate.Text.Trim().Replace("'", "''"));

        objDO.strPriority  = ddlPriorityType.SelectedItem.Value;
        objDO.strIpAddress = ip;
        if (!string.IsNullOrEmpty(txtContactPerson.Text.Trim()) && txtContactPerson.Text.Trim() != "Contact person")
        {
            objDO.strContactPerson = txtContactPerson.Text.Trim().Replace("'", "''");
        }
        if (!string.IsNullOrEmpty(txtContactPerNumber.Text.Trim()) && txtContactPerNumber.Text.Trim() != "Contact person number")
        {
            objDO.strContactNumber = txtContactPerNumber.Text.Trim().Replace("'", "''");
        }

        if (!string.IsNullOrEmpty(Convert.ToString(hdnUpdateEventId.Value)))
        {
            objDO.intGrpEventId = Convert.ToInt32(hdnUpdateEventId.Value);
            objDO.intModifiedBy = Convert.ToInt32(ViewState["UserID"]);
            objDA.AddEditDel_Scrl_GroupEventsTbl(objDO, DA_Scrl_GroupEventsTbl.Scrl_GroupEventsTbl.Update);
        }
        else
        {
            objDA.AddEditDel_Scrl_GroupEventsTbl(objDO, DA_Scrl_GroupEventsTbl.Scrl_GroupEventsTbl.Insert);
        }
        lblDateMessage.Text = "";
        lbleventColor.Text  = "";
        if (ISAPIURLACCESSED == "1")
        {
            try
            {
                StringBuilder UserURL = new StringBuilder();
                UserURL.Append(APIURL);
                UserURL.Append("createEvent.action?");
                UserURL.Append("groupId=GRP");
                UserURL.Append(ViewState["intGroupId"]);
                UserURL.Append("&eventId = USR");
                UserURL.Append(objDO.intNewEventID);
                UserURL.Append("&groupOwnerId=USR");
                UserURL.Append(Session["GroupOwnerId"]);
                UserURL.Append("&insertDt=");
                UserURL.Append(DateTime.Now);
                UserURL.Append("&content=");
                UserURL.Append(objDO.strDescription);
                UserURL.Append("&scope=");
                UserURL.Append(ddlPriorityType.SelectedItem.Text);
                UserURL.Append("&title=");
                UserURL.Append(objDO.strTitle);


                HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL.ToString());
                myRequest1.Method = "GET";
                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 Event";
                objAPILogDO.strResponse  = result;
                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                objAPILogDO.strIPAddress = ip;
                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
            }
            catch
            {
            }
        }

        if (!string.IsNullOrEmpty(Convert.ToString(hdnUpdateEventId.Value)))
        {
            lblSuccess.Text = "Event updated successfully.";
        }
        else
        {
            lblSuccess.Text = "Event created successfully.";
        }

        BindTitle();
        eventpopup.Style.Add("display", "none");
        divSuccessEvent.Style.Add("display", "block");
        divSuccessEvents.Style.Add("display", "none");
        ClearControl();
    }
    protected void lnkPostForum_Click(object sender, EventArgs e)
    {
        divDeletesucess.Style.Add("display", "none");
        if (txtPostForum.Text != "")
        {
            lblmsg.Visible = false;
            if (!string.IsNullOrEmpty(txtPostForum.Text))
            {
                if (Application["ConnectedUserListOnComment"] != null)
                {
                    DataTable dtContent = (DataTable)Application["ConnectedUserListOnComment"];
                    if (dtContent.Rows.Count > 0)
                    {
                        if (txtPostForum.Text.Contains("'"))
                        {
                            txtPostForum.Text = txtPostForum.Text.Replace("'", "''");
                        }
                        for (int i = 0; i < dtContent.Rows.Count; i++)
                        {
                            string AutoSugestName = Convert.ToString(dtContent.Rows[i]["Name"]);
                            bool   contains       = txtPostForum.Text.IndexOf(AutoSugestName, StringComparison.OrdinalIgnoreCase) >= 0;
                            if (contains == true)
                            {
                                int CommentUserId = Convert.ToInt32(dtContent.Rows[i]["intRegistrationId"].ToString());
                                if (String.IsNullOrEmpty(CommaSepratedIDs))
                                {
                                    PostForumHashSeprated = Regex.Replace(txtPostForum.Text, AutoSugestName, "#" + Convert.ToString(CommentUserId), RegexOptions.IgnoreCase);
                                    CommaSepratedIDs     += CommentUserId;
                                }
                                else
                                {
                                    PostForumHashSeprated = Regex.Replace(PostForumHashSeprated, AutoSugestName, "#" + Convert.ToString(CommentUserId), RegexOptions.IgnoreCase);
                                    CommaSepratedIDs     += "," + CommentUserId;
                                }
                            }
                        }
                    }
                }
                string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (ip == null)
                {
                    ip = Request.ServerVariables["REMOTE_ADDR"];
                }
                objDOBForumPosting.strIpAddress = ip;

                if (ViewState["intForumReplyLikeShareId"] == null)
                {
                    objDOBForumPosting.strCommentUserId  = CommaSepratedIDs;
                    objDOBForumPosting.intRegistrationId = Convert.ToInt32(Session["ExternalUserId"]);
                    objDOBForumPosting.intGroupId        = Convert.ToInt32(ViewState["intGroupId"]);

                    objDOBForumPosting.strRepLiShStatus = "RE";
                    if (!string.IsNullOrEmpty(PostForumHashSeprated))
                    {
                        objDOBForumPosting.strComment = PostForumHashSeprated;
                    }
                    else if (!string.IsNullOrEmpty(txtPostForum.Text))
                    {
                        objDOBForumPosting.strComment = txtPostForum.Text.Trim().Replace("''", "'");
                    }

                    objDOBForumPosting.intForumPostingId = Convert.ToInt32(Request.QueryString["ForumId"]);
                    objDOBForumPosting.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"]);
                    objDAForumPosting.AddEditDel_Scrl_UserForumPostingTbl(objDOBForumPosting, DA_Scrl_UserForumPosting.Scrl_UseForumPosting.InsertPostReply);
                    ViewState["ForumReplyLikeShareId"] = objDOBForumPosting.intForumReplyLikeShareId;

                    if (ISAPIURLACCESSED != "0")
                    {
                        try
                        {
                            String url = APIURL + "addCommentOnForum.action?" +
                                         "commentId=" + objDOBForumPosting.intForumReplyLikeShareId +
                                         "&forumUid=" + objDOBForumPosting.intForumPostingId +
                                         "&groupid=" + objDOBForumPosting.intAddedBy +
                                         "&commentByUid=" + null +
                                         "&insertDt=" + DateTime.Now +
                                         "&content=" + objDOBForumPosting.strComment;

                            HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url);
                            myRequest1.Method = "GET";
                            if (ISAPIResponse == "1")
                            {
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();
                                objAPILogDO.strURL       = url;
                                objAPILogDO.strAPIType   = "Forum Comment";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.strIPAddress = ip;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                        }
                        catch { }
                    }

                    txtPostForum.Text = "";
                    GetForumDetails();
                    string ID = txtPostForum.ClientID;
                    hdnForumrRefresh.Value = ID;
                }
                else
                {
                    objDOBForumPosting.ForumReplyLikeShareId = Convert.ToInt32(ViewState["intForumReplyLikeShareId"]);
                    objDOBForumPosting.strCommentUserId      = CommaSepratedIDs;
                    objDOBForumPosting.intRegistrationId     = Convert.ToInt32(Session["ExternalUserId"]);
                    objDOBForumPosting.intGroupId            = Convert.ToInt32(ViewState["intGroupId"]);

                    objDOBForumPosting.strRepLiShStatus = "RE";
                    if (!string.IsNullOrEmpty(PostForumHashSeprated))
                    {
                        objDOBForumPosting.strComment = PostForumHashSeprated;
                    }
                    else if (!string.IsNullOrEmpty(txtPostForum.Text))
                    {
                        objDOBForumPosting.strComment = txtPostForum.Text.Trim().Replace("''", "'");
                    }

                    objDOBForumPosting.intForumPostingId = Convert.ToInt32(Request.QueryString["ForumId"]);
                    objDOBForumPosting.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"]);
                    objDAForumPosting.AddEditDel_Scrl_UserForumPostingTbl(objDOBForumPosting, DA_Scrl_UserForumPosting.Scrl_UseForumPosting.UpdatePostReply);
                    ViewState["ForumReplyLikeShareId"] = objDOBForumPosting.intForumReplyLikeShareId;

                    if (ISAPIURLACCESSED != "0")
                    {
                        try
                        {
                            String url = APIURL + "addCommentOnForum.action?" +
                                         "commentId=" + objDOBForumPosting.intForumReplyLikeShareId +
                                         "&forumUid=" + objDOBForumPosting.intForumPostingId +
                                         "&groupid=" + objDOBForumPosting.intAddedBy +
                                         "&commentByUid=" + null +
                                         "&insertDt=" + DateTime.Now +
                                         "&content=" + objDOBForumPosting.strComment;

                            HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url);
                            myRequest1.Method = "GET";
                            if (ISAPIResponse == "1")
                            {
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();
                                objAPILogDO.strURL       = url;
                                objAPILogDO.strAPIType   = "Forum Comment";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.strIPAddress = ip;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                        }
                        catch { }
                    }

                    txtPostForum.Text = "";
                    BindlstReplyForum();
                    GetForumDetails();
                    string ID = txtPostForum.ClientID;
                    hdnForumrRefresh.Value = ID;
                    ViewState["intForumReplyLikeShareId"] = null;
                }
            }
            else
            {
                lblmsg.Visible = true;
                return;
            }
        }
        else
        {
            lblmsg.Visible = true;
            return;
        }

        BindlstReplyForum();
    }
Exemplo n.º 6
0
    protected void lnkPopupOK_Click(object sender, EventArgs e)
    {
        int intRequestJoinId = 0;

        if (Request.QueryString["AccRegId"] != null)
        {
            objGrpJoinDO.intRegistrationId = Convert.ToInt32(Request.QueryString["AccRegId"]);
            objGrpJoinDO.inGroupId         = Convert.ToInt32(Request.QueryString["GrpId"]);
            objGrpJoinDO.PageSize          = 100;
            objGrpJoinDO.Currentpage       = 1;
            DataTable dtSearch = objGrpJoinDA.GetDataTable(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.SingleRecord);

            if (dtSearch.Rows.Count > 0)
            {
                intRequestJoinId = Convert.ToInt32(dtSearch.Rows[0]["JoinId"]);

                if (Convert.ToString(Session["ExternalUserId"]) != "" && Session["ExternalUserId"] != null)
                {
                    objGrpJoinDO.intRegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
                    objGrpJoinDO.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"].ToString());
                    objGrpJoinDO.intRequestJoinId  = intRequestJoinId;
                    objGrpJoinDO.strIpAddress      = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    objGrpJoinDO.isAccepted        = 1;
                    if (objGrpJoinDO.strIpAddress == null)
                    {
                        objGrpJoinDO.strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objGrpJoinDA.AddEditDel_Scrl_UserGroupJoin(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.Update);
                    try
                    {
                        string UserURL = "";

                        if (ISAPIURLACCESSED == "1")
                        {
                            UserURL = APIURL + "addMemberToGroup.action?" +
                                      "groupId=GRP" + Request.QueryString["GrpId"] +
                                      "&members=USR" + Request.QueryString["AccRegId"];

                            HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL);
                            myRequest1.Method = "GET";
                            if (ISAPIResponse == "1")
                            {
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();
                                objAPILogDO.strURL       = UserURL;
                                objAPILogDO.strAPIType   = "Group Member";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDO.strIPAddress = objGrpJoinDO.strIpAddress;
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                        }
                    }
                    catch { }
                }
                else
                {
                    return;
                }
            }

            EmailId   = Convert.ToString(dtSearch.Rows[0]["vchrUserName"]);
            Name      = Convert.ToString(dtSearch.Rows[0]["Name"]);
            GroupName = Convert.ToString(dtSearch.Rows[0]["strGroupName"]);

            divPopupMember.Style.Add("display", "none");
            divSuccessAcceptMember.Style.Add("display", "block");
            lblSuccess.Text = "Group joining request accepted successfully and a mail is sent to the member.";
            SendGroupMail(EmailId, Name, GroupName);
        }
        else if (Request.QueryString["RejRegId"] != null)
        {
            objGrpJoinDO.intRegistrationId = Convert.ToInt32(Request.QueryString["RejRegId"]);
            objGrpJoinDO.inGroupId         = Convert.ToInt32(Request.QueryString["GrpId"]);
            objGrpJoinDO.PageSize          = 100;
            objGrpJoinDO.Currentpage       = 1;
            DataTable dtSearch = objGrpJoinDA.GetDataTable(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.SingleRecord);

            if (dtSearch.Rows.Count > 0)
            {
                intRequestJoinId = Convert.ToInt32(dtSearch.Rows[0]["intRequestJoinId"]);

                if (Convert.ToString(Session["ExternalUserId"]) != "" && Session["ExternalUserId"] != null)
                {
                    objGrpJoinDO.intRegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
                    objGrpJoinDO.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"].ToString());
                    objGrpJoinDO.intRequestJoinId  = intRequestJoinId;
                    objGrpJoinDO.strIpAddress      = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    objGrpJoinDO.isAccepted        = 2;
                    if (objGrpJoinDO.strIpAddress == null)
                    {
                        objGrpJoinDO.strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    objGrpJoinDA.AddEditDel_Scrl_UserGroupJoin(objGrpJoinDO, DA_Scrl_UserGroupJoin.Scrl_UserGroupJoin.Update);
                    DeleteMemberRole();

                    try
                    {
                        string UserURL = "";

                        if (ISAPIURLACCESSED == "1")
                        {
                            UserURL = APIURL + "removeMemberFromGroup.action?" +
                                      "groupId=GRP" + Request.QueryString["GrpId"] +
                                      "&members=USR" + Request.QueryString["RejRegId"];

                            HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL);
                            myRequest1.Method = "GET";
                            if (ISAPIResponse == "1")
                            {
                                WebResponse  myResponse1 = myRequest1.GetResponse();
                                StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                                String       result      = sr.ReadToEnd();
                                objAPILogDO.strURL       = UserURL;
                                objAPILogDO.strAPIType   = "Group Member";
                                objAPILogDO.strResponse  = result;
                                objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                                objAPILogDO.strIPAddress = objGrpJoinDO.strIpAddress;
                                objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                            }
                        }
                    }
                    catch { }
                }
                else
                {
                    return;
                }
            }

            divPopupMember.Style.Add("display", "none");
            divSuccessAcceptMember.Style.Add("display", "block");
            lblSuccess.Text = "Group joining request rejected successfully.";
        }
        else if (Request.QueryString["DisConnFrnd"] != null)
        {
            Response.Redirect("Home.aspx?RegId=" + Request.QueryString["DisConnFrnd"]);
            divPopupMember.Style.Add("display", "none");
        }
        else if (Request.QueryString["ConnFrnd"] != null)
        {
            Response.Redirect("Home.aspx?RegId=" + Request.QueryString["ConnFrnd"]);
            divPopupMember.Style.Add("display", "none");
        }
        else if (Request.QueryString["MessId"] != null)
        {
            objRecmndDO.intInvitedUserId = Convert.ToInt32(ViewState["RegId"]);
            if (Convert.ToString(Session["ExternalUserId"]) != "" && Session["ExternalUserId"] != null)
            {
                objRecmndDO.intRegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
            }
            else
            {
                return;
            }

            objRecmndDO.StrRecommendation = txtBody.InnerText.Trim().Replace("'", "''").Replace("\n", "<br>");
            objRecmndDO.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"].ToString());
            objRecmndDO.strIpAddress      = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (objRecmndDO.strIpAddress == null)
            {
                objRecmndDO.strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            objRecmndDA.Scrl_AddEditDelRecommendations(objRecmndDO, DA_Scrl_UserRecommendation.Scrl_UserRecommendation.Add);
            txtBody.InnerText = "";
            Response.Redirect("Home.aspx?RegId=" + Request.QueryString["MessId"]);
            divPopupMember.Style.Add("display", "none");
        }
        else if (Request.QueryString["GrpReqJoinId"] != null || Request.QueryString["GrpAutoJoinId"] != null || Request.QueryString["GrpUnJoinId"] != null)
        {
            Response.Redirect("SearchGroup.aspx");
            divPopupMember.Style.Add("display", "none");
        }
        else if (Request.QueryString["GrpAutoJoin"] != null)
        {
            int GrpAutoJoin = Convert.ToInt32(Request.QueryString["GrpAutoJoin"]);
            divPopupMember.Style.Add("display", "none");
            Response.Redirect("groups-members.aspx?GrpId=" + GrpAutoJoin);
        }
        else if (Request.QueryString["GrpUnJoin"] != null)
        {
            int GrpUnJoin = Convert.ToInt32(Request.QueryString["GrpUnJoin"]);
            divPopupMember.Style.Add("display", "none");
            Response.Redirect("groups-members.aspx?GrpId=" + GrpUnJoin);
        }
        else if (Request.QueryString["MessPepId"] != null)
        {
            objRecmndDO.intInvitedUserId = Convert.ToInt32(ViewState["RegId"]);
            if (Convert.ToString(Session["ExternalUserId"]) != "" && Session["ExternalUserId"] != null)
            {
                objRecmndDO.intRegistrationId = Convert.ToInt32(Session["ExternalUserId"].ToString());
            }
            else
            {
                return;
            }

            objRecmndDO.StrRecommendation = txtBody.InnerText.Trim().Replace("'", "''").Replace("\n", "<br>");
            objRecmndDO.intAddedBy        = Convert.ToInt32(Session["ExternalUserId"].ToString());
            objRecmndDO.strIpAddress      = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (objRecmndDO.strIpAddress == null)
            {
                objRecmndDO.strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            objRecmndDA.Scrl_AddEditDelRecommendations(objRecmndDO, DA_Scrl_UserRecommendation.Scrl_UserRecommendation.Add);
            txtBody.InnerText = "";
            Response.Redirect("SearchPeople.aspx?ViewAll=" + Request.QueryString["ViewAll"]);
            divPopupMember.Style.Add("display", "none");
        }
    }
Exemplo n.º 7
0
    protected void lnkSubmitBlog_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(CKDescription.InnerText.Trim()))
        {
            string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ip == null)
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }

            if (ViewState["intBlogId"] == null)
            {
                objblogdo.strIPAddress = ip;
                objblogdo.intAddedBy   = Convert.ToInt32(Session["ExternalUserId"]);
                //Bug 9 HTML Validations
                objblogdo.strBlogHeading = Validations.validateHtmlInput(Convert.ToString(txtTitle.Text.Replace("'", "''").Trim()));
                string editor = CKDescription.InnerText.Trim().Replace(",", "''").Replace("<p>", "<br>").Replace("</p>", "");
                string noHTML = Regex.Replace(editor, @"<[^>]+>|&nbsp;", "").Trim();
                objblogdo.strBlogTitle = Regex.Replace(noHTML, @"\s{2,}", " ");
                string PhotoPath = "";
                if (UploadPics.HasFile)
                {
                    string name = UploadPics.FileName;
                    string ext  = System.IO.Path.GetExtension(name);

                    if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
                    {
                        lblMessage.Visible  = true;
                        lblMessage.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                        lblMessage.CssClass = "RedErrormsg";
                        return;
                    }
                    int FileLength = UploadPics.PostedFile.ContentLength;
                    if (FileLength <= 3145728)
                    {
                        PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(UploadPics.FileName).ToString();
                        UploadPics.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
                        objblogdo.strBlogPicture = PhotoPath;
                    }
                    else
                    {
                        lblMessage.Visible  = true;
                        lblMessage.Text     = "image size should be less than or equal to 3MB.'";
                        lblMessage.CssClass = "RedErrormsg";
                        return;
                    }
                }
                objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.Add);

                if (!string.IsNullOrEmpty(Convert.ToString(objblogdo.intOutId)) || objblogdo.intOutId != 0)
                {
                    ViewState["intOutId"] = objblogdo.intOutId;
                    // string totalMembers = hdnsubject.Value;
                    //  string[] members = null;
                    List <KeyValuePair <string, string> > subJectValues = txtSubjectList.GetSelectedValues();

                    if (subJectValues != null && subJectValues.Count > 0)
                    {
                        string[] members = subJectValues.Select(s => (string)s.Value).ToArray();
                        for (int i = 0; i < members.Length; i++)
                        {
                            if (Convert.ToString(members.GetValue(i)) != "")
                            {
                                int ID = Convert.ToInt32(members.GetValue(i));
                                objblogdo.intBlogId            = Convert.ToInt32(ViewState["intOutId"]);
                                objblogdo.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                                objblogdo.intSubjectCategoryId = ID;
                                objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.ADDSelectedSubCatId);
                            }
                        }
                    }
                    clear();
                    lblSuccess.Text = "Blog Added Successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg1", "CallOnRequestSucess();", true);
                    divSuccess.Style.Add("display", "block");
                }
                //              if (ISAPIURLACCESSED != "0")
                //              {
                //                  try
                //                  {

                //StringBuilder url = new StringBuilder();
                //url.Append(APIURL);
                //url.Append("addBlog.action?");
                //url.Append("blogId =");
                //url.Append(objblogdo.intBlogId);
                //url.Append("&userId=");
                //url.Append(objblogdo.intAddedBy);
                //url.Append("&userName="******"&insertDt=");
                //url.Append(DateTime.Now);
                //url.Append("&content=");
                //url.Append(objblogdo.strBlogTitle);
                //url.Append("&title=");
                //url.Append(objblogdo.strBlogHeading);


                //                      HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                //                      myRequest1.Method = "GET";
                //                      WebResponse myResponse1 = myRequest1.GetResponse();
                //                      if (ISAPIResponse != "0")
                //                      {
                //                          StreamReader sr = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                //                          String result = sr.ReadToEnd();
                //                          objAPILogDO.strURL = url.ToString();
                //                          objAPILogDO.strAPIType = "Write Blog";
                //                          objAPILogDO.strResponse = result;
                //                          objAPILogDO.strIPAddress = ip;
                //                          objAPILogDO.intAddedBy = Convert.ToInt32(ViewState["UserID"]);
                //                          objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                //                      }
                //                  }
                //                  catch { }
                //              }
                if (ISAPIURLACCESSED != "0")
                {
                    try
                    {
                        StringBuilder url = new StringBuilder();
                        url.Append(APIURL);
                        url.Append("addBlog?");
                        url.Append("blogId=");
                        url.Append(Convert.ToInt32(ViewState["intOutId"]));
                        url.Append("&userId=");
                        url.Append(objblogdo.intAddedBy);
                        url.Append("&insertDt=");
                        url.Append(DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
                        url.Append("&title=");
                        url.Append(objblogdo.strBlogHeading);
                        url.Append("&content=");
                        url.Append(objblogdo.strBlogTitle);
                        url.Append("&scope=");
                        url.Append("ALL");
                        url.Append("&userName="******"GET";
                        WebResponse myResponse1 = myRequest1.GetResponse();
                        //if (ISAPIResponse != "0")
                        //{
                        StreamReader sr     = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result = sr.ReadToEnd();
                        objAPILogDO.strURL       = url.ToString();
                        objAPILogDO.strAPIType   = "Write Blog";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = ip;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                        //}
                    }
                    catch { }
                }
            }
            else
            {
                objblogdo.intBlogId      = Convert.ToInt32(ViewState["intBlogId"]);
                objblogdo.strIPAddress   = ip;
                objblogdo.intAddedBy     = Convert.ToInt32(Session["ExternalUserId"]);
                objblogdo.strBlogHeading = Convert.ToString(txtTitle.Text.Replace("'", "''").Trim());
                string editor = CKDescription.InnerText.Trim().Replace(",", "''").Replace("<p>", "<br>").Replace("</p>", "");
                string noHTML = Regex.Replace(editor, @"<[^>]+>|&nbsp;", "").Trim();
                objblogdo.strBlogTitle = Regex.Replace(noHTML, @"\s{2,}", " ");
                string PhotoPath = "";

                if (UploadPics.HasFile)
                {
                    string name = UploadPics.FileName;
                    string ext  = System.IO.Path.GetExtension(name);
                    if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
                    {
                        lblMessage.Visible  = true;
                        lblMessage.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                        lblMessage.CssClass = "RedErrormsg";
                        return;
                    }

                    int FileLength = UploadPics.PostedFile.ContentLength;
                    if (FileLength <= 3145728)
                    {
                        PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(UploadPics.FileName).ToString();
                        UploadPics.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
                        objblogdo.strBlogPicture = PhotoPath;
                    }
                    else
                    {
                        lblMessage.Visible  = true;
                        lblMessage.Text     = "image size should be less than or equal to 3MB.'";
                        lblMessage.CssClass = "RedErrormsg";
                        return;
                    }
                }

                objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.Update);

                if (!string.IsNullOrEmpty(Convert.ToString(objblogdo.intOutId)) || objblogdo.intOutId != 0)
                {
                    objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.DeleteSelectedSubCatId);
                    //  string totalMembers = hdnsubject.Value;
                    // string[] members = totalMembers.Split(',');
                    List <KeyValuePair <string, string> > subJectValues = txtSubjectList.GetSelectedValues();

                    if (subJectValues != null && subJectValues.Count > 0)
                    {
                        string[] members = subJectValues.Select(s => (string)s.Value).ToArray();
                        for (int i = 0; i < members.Length; i++)
                        {
                            if (Convert.ToString(members.GetValue(i)) != "")
                            {
                                int ID = Convert.ToInt32(members.GetValue(i));
                                objblogdo.intBlogId            = Convert.ToInt32(ViewState["intBlogId"]);
                                objblogdo.intAddedBy           = Convert.ToInt32(ViewState["UserID"]);
                                objblogdo.intSubjectCategoryId = ID;
                                objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.ADDSelectedSubCatId);
                            }
                        }
                    }
                    clear();
                    lblSuccess.Text = "Blog Update successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CallPostimg1", "CallOnRequestSucess();", true);
                    divSuccess.Style.Add("display", "block");
                }

                if (ISAPIURLACCESSED != "0")
                {
                    try
                    {
                        StringBuilder url = new StringBuilder();
                        url.Append(APIURL);
                        url.Append("updateBlog?");
                        url.Append("blogId =");
                        url.Append(objblogdo.intBlogId);
                        url.Append("&userId =");
                        url.Append(objblogdo.intAddedBy);
                        url.Append("&insertDt=");
                        url.Append(DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
                        url.Append("&title=");
                        url.Append(objblogdo.strBlogHeading);
                        url.Append("&content=");
                        url.Append(objblogdo.strBlogTitle);
                        url.Append("&scope=");
                        url.Append("ALL");
                        url.Append("&userName="******"GET";
                        WebResponse myResponse1 = myRequest1.GetResponse();
                        //if (ISAPIResponse != "0")
                        //{
                        StreamReader sr     = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                        String       result = sr.ReadToEnd();

                        objAPILogDO.strURL       = url.ToString();
                        objAPILogDO.strAPIType   = "Update Blog";
                        objAPILogDO.strResponse  = result;
                        objAPILogDO.strIPAddress = ip;
                        objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                        objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                        //}
                    }
                    catch { }
                }
            }
        }
        else
        {
            lblSuMess.Text      = "Please enter blog.";
            lblSuMess.ForeColor = System.Drawing.Color.Red;
            divSuccess.Style.Add("display", "none");
        }
    }
Exemplo n.º 8
0
    public string GetPdfPathForWhatsApp(string UserId, string ContentID, string hdnDivContent, string ip, string hdnMarkMaxCount, string lblCaseTitle)
    {
        string        directory = string.Empty;
        string        fileName  = string.Empty;
        StringBuilder text      = new StringBuilder(hdnDivContent);

        #region GetContentForPDF Method Code
        StringBuilder UserURL = new StringBuilder(ConfigurationManager.AppSettings["APIURL"]);
        UserURL.Append("downloadDocument.action?");
        UserURL.Append("downloadByUId=");
        UserURL.Append(UserId);
        UserURL.Append("&downloadedParentId=");
        UserURL.Append(ContentID);
        UserURL.Append("&downloadType=");
        UserURL.Append("free");

        DO_Scrl_APILogDetailsTbl objAPILogDO = new DO_Scrl_APILogDetailsTbl();
        DA_Scrl_APILogDetailsTbl objAPILogDA = new DA_Scrl_APILogDetailsTbl();
        try
        {
            if (ConfigurationManager.AppSettings["ISAPIURLACCESSED"] == "1")
            {
                HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(UserURL.ToString());
                myRequest1.Method = "GET";
                WebResponse myResponse1 = myRequest1.GetResponse();
                if (ConfigurationManager.AppSettings["ISAPIResponse"] != "0")
                {
                    StreamReader sr     = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                    String       result = sr.ReadToEnd();
                    objAPILogDO.strURL       = UserURL.ToString();
                    objAPILogDO.intAddedBy   = Convert.ToInt32(UserId);
                    objAPILogDO.strAPIType   = "Share On WhatsApp";
                    objAPILogDO.strResponse  = result;
                    objAPILogDO.strIPAddress = ip;
                    objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                }
            }

            //string texta = hdnDivContent.Value;

            text = text.Replace("&quot;", "").Replace("<br>", "<br />").Replace("<br >", "<br />");
            int countCdiv = CountStringOccurrences(text.ToString(), "</div>");
            int countdiv  = CountStringOccurrences(text.ToString(), "<div");
            if (countCdiv == 0 && countdiv == 0)
            {
                int txtL = text.Length;
                text = text.Insert(txtL, "</div>");
                text = text.Insert(0, "<div>");
            }

            if (Convert.ToInt32(hdnMarkMaxCount) > 0)
            {
                for (int i = 0; i <= Convert.ToInt32(hdnMarkMaxCount); i++)
                {
                    string spanOpen  = "<span" + i;
                    string replace   = "<span";
                    string pattern   = spanOpen;
                    string result    = Regex.Replace(text.ToString(), pattern, replace, RegexOptions.IgnoreCase);
                    string spanClose = "</span" + i;
                    replace = "</span";
                    pattern = spanClose;
                    result  = Regex.Replace(result.ToString(), pattern, replace, RegexOptions.IgnoreCase);
                    text    = new StringBuilder(result);
                }
                text = text.Replace("class=\"preced\"", "style=\"background-color: #ffeca0;\"").Replace("class=\"rediod\"", "style=\"background-color: #AECF00;\"").Replace("class=\"issuss\"", "style=\"background-color: #faa69d;\"").Replace("span0", "span").Replace("span1", "span").Replace("span2", "span").Replace("span3", "span").Replace("span4", "span").Replace("span5", "span");
                text = text.Replace("class=\"factss\"", "style=\"background-color: #9dc6fa;\"").Replace("class=\"highls\"", "style=\"background-color: Lime;\"").Replace("class=\"orbits\"", "style=\"background-color: #f8adef;\"").Replace("class=\"ImpPss\"", "style=\"background-color: #b0ffd2;\"");
            }
        }
        catch
        {
        }
        #endregion
        #region CreatePdf() Method Code
        try
        {
            directory = HttpContext.Current.Server.MapPath("~\\SharingDoc\\");

            Random generator = new Random();
            int    r         = generator.Next(1, 1000000);
            string s         = r.ToString().PadLeft(6, '0');

            //DateTime dt = System.DateTime.Now;
            //string timestam = Convert.ToString(dt.Day) + Convert.ToString(dt.Month) + Convert.ToString(dt.Year) + s;
            //fileName = "CaseDocument_" + timestam + ".pdf";
            fileName = "CaseDocument_" + ContentID + ".pdf";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            using (var msOutput = new FileStream(directory + fileName, FileMode.Create))
            {
                using (var document = new Document(PageSize.A4, 30, 30, 30, 30))
                {
                    using (var writer = PdfWriter.GetInstance(document, msOutput))
                    {
                        document.Open();



                        var       example_css = @".body{font-family: 'Times New Roman'}";
                        Font      contentFont = FontFactory.GetFont("Times New Roman", 16.0f, iTextSharp.text.Font.BOLD);
                        Paragraph para        = new Paragraph(lblCaseTitle, contentFont);
                        para.Alignment = Element.ALIGN_CENTER;
                        document.Add(para);
                        Paragraph para1 = new Paragraph(" ", contentFont);
                        document.Add(para1);
                        document.HtmlStyleClass = @".IContent{font-family: Times New Roman;text-align: justify;font-size: 22px;}";

                        using (TextReader reader = new StringReader(Convert.ToString(text)))
                        {
                            //Parse the HTML and write it to the document
                            XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader);
                        }
                        document.Close();
                    }
                    #endregion
                }
            }
            addWatermarkInsidePDF(fileName);
        }
        catch (Exception Ex)
        {
            fileName = string.Empty;
            Ex.Message.ToString();
        }
        return(fileName);
    }
Exemplo n.º 9
0
    protected void lnkDeleteConfirm_Click(object sender, EventArgs e)
    {
        string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

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

        if (ViewState["blognames"] != null)
        {
            objblogdo.intBlogId = Convert.ToInt32(ViewState["intBlogId"]);
            objblogda.AddEditDel_NewBlog(objblogdo, DA_NewBlogs.Blog.DeleteBlog);

            if (ip == null)
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }
            objLog.intAddedBy    = Convert.ToInt32(ViewState["UserID"]);
            objLog.intActionId   = Convert.ToInt32(ViewState["intBlogId"]);
            objLog.strAction     = "Blog";
            objLog.strActionName = ViewState["blognames"].ToString();
            objLog.strIPAddress  = ip;
            objLog.intDeletedBy  = Convert.ToInt32(ViewState["UserID"]);
            objLog.SectionId     = 24; // Blog Delete
            objLogD.AddEditDel_Scrl_LogDetailsMaster(objLog, DA_Logdetails.LogDetails.Insert);

            if (ISAPIURLACCESSED != "0")
            {
                try
                {
                    StringBuilder url = new StringBuilder();
                    url.Append(APIURL);
                    url.Append("removeBlog?");
                    url.Append("blogId=");
                    url.Append(Convert.ToInt32(ViewState["intBlogId"]));
                    url.Append("&userId=");
                    url.Append(Convert.ToInt32(ViewState["UserID"]));

                    HttpWebRequest myRequest1 = (HttpWebRequest)WebRequest.Create(url.ToString());
                    myRequest1.Method = "GET";
                    WebResponse  myResponse1 = myRequest1.GetResponse();
                    StreamReader sr          = new StreamReader(myResponse1.GetResponseStream(), System.Text.Encoding.UTF8);
                    String       result      = sr.ReadToEnd();

                    objAPILogDO.strURL       = url.ToString();
                    objAPILogDO.strAPIType   = "Deleting Blog";
                    objAPILogDO.strResponse  = result;
                    objAPILogDO.strIPAddress = ip;
                    objAPILogDO.intAddedBy   = Convert.ToInt32(ViewState["UserID"]);
                    objAPILogDA.AddEditDel_Scrl_APILogDetailsTbl(objAPILogDO, DA_Scrl_APILogDetailsTbl.Scrl_APILogDetailsTbl.Insert);
                }
                catch { }
            }

            //Response.Redirect("AllBlogs.aspx");
            Response.Redirect("~/AllBlogs.aspx?DeleteBlog=true");
        }
        else
        {
            objblogdo.intCommentId = Convert.ToInt32(ViewState["hdnCommentID"]);
            objblogdo.intBlogId    = Convert.ToInt32(ViewState["intBlogId"]);
            objblogdo.intAddedBy   = Convert.ToInt32(Session["ExternalUserId"]);
            objblogda.AddEditDel_NewBlogComment(objblogdo, DA_NewBlogs.BlogCommnet.Delete);
            BindBlogList();
            BindComments();
            divDeletesucess.Style.Add("display", "none");

            if (ip == null)
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }
            objLog.intAddedBy    = Convert.ToInt32(ViewState["UserID"]);
            objLog.intActionId   = Convert.ToInt32(ViewState["hdnCommentID"]);
            objLog.strAction     = "Blog Comment";
            objLog.strActionName = ViewState["blogCommentnames"].ToString();
            objLog.strIPAddress  = ip;
            objLog.intDeletedBy  = Convert.ToInt32(ViewState["UserID"]);
            objLog.SectionId     = 24; // Blog Delete
            objLogD.AddEditDel_Scrl_LogDetailsMaster(objLog, DA_Logdetails.LogDetails.Insert);
            //Response.Redirect("~/BlogsComments.aspx?DeleteComment=true");
        }
    }