public string ChangePassword(string OldPassword, string NewPassword, int EmpId, int Operation)
        {
            SqlConnection con = new SqlConnection();

            Common_Library.CommonFunctions funMail = new Common_Library.CommonFunctions();
            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                con                  = new SqlConnection();
                connection           = ConfigurationManager.ConnectionStrings[Constants.connection].ConnectionString;
                con.ConnectionString = connection;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = con;
                cmd.CommandText    = Constants.UspChangePassword;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 300;
                con.Open();
                cmd.Parameters.AddWithValue(Constants.paramOldPassword, OldPassword);
                cmd.Parameters.AddWithValue(Constants.ParamNewPassword, NewPassword);
                cmd.Parameters.AddWithValue(Constants.paramFKEmpId, EmpId);
                cmd.Parameters.AddWithValue(Constants.paramOperId, Operation);

                IDataReader dataReader = cmd.ExecuteReader();
                DataTable   dataTable  = new DataTable(Constants.loginInfoTable);
                dataTable.Load(dataReader);
                if (dataTable.Rows.Count > 0)
                {
                    if (dataTable.Columns.Contains("ToAddress"))
                    {
                        string msgBody = "Hi " + Convert.ToString(dataTable.Rows[0]["Name"]) + ",<br/><br/> The password for your Nuvento Portal account has been successfully changed." +
                                         " If you did not request this change, please contact support immediately.";
                        if (funMail.SendEmail(Convert.ToString(dataTable.Rows[0]["ToAddress"]), "", "", "Password Change", msgBody))
                        {
                            return(JsonConvert.SerializeObject("{\"UserUpdated\" : 1}", Formatting.Indented));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(dataTable, Formatting.Indented));
                    }
                }
                else
                {
                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
                funMail = null;
            }
        }
        public string GetFilterForGrid(string JsonData, int EmpId, int Offset, int RowCount, int Operation)
        {
            //string XmlField1, string XmlField2, string XmlField3, string XmlField4, string XmlField5,
            //string XmlField6, string XmlField7,string XmlField8
            Dictionary <string, string> dictvalues;
            SqlConnection con = new SqlConnection();

            Common_Library.CommonFunctions obj = new Common_Library.CommonFunctions();
            try
            {
                con                  = new SqlConnection();
                connection           = ConfigurationManager.ConnectionStrings[Constants.connection].ConnectionString;
                con.ConnectionString = connection;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = con;
                cmd.CommandText    = Constants.UspFilterGrid;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 300;
                con.Open();
                if (JsonData != string.Empty)
                {
                    dictvalues = JsonConvert.DeserializeObject <Dictionary <string, string> >(JsonData);
                    foreach (KeyValuePair <string, string> item in dictvalues)
                    {
                        cmd.Parameters.AddWithValue("@" + item.Key, obj.BuildXml(item.Value));
                    }
                }
                cmd.Parameters.AddWithValue(Constants.colEmpId, EmpId);
                cmd.Parameters.AddWithValue(Constants.paramOffset, Offset);
                cmd.Parameters.AddWithValue(Constants.paramRowCount, RowCount);
                cmd.Parameters.AddWithValue(Constants.paramOperId, Operation);
                IDataReader dataReader = cmd.ExecuteReader();
                DataTable   dataTable  = new DataTable(Constants.employeeProfileCompletedTable);
                dataTable.Load(dataReader);
                if (dataTable.Rows.Count > 0)
                {
                    return(JsonConvert.SerializeObject(dataTable, Formatting.Indented));
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                return("");
            }
            finally
            {
                con.Close();
                dictvalues = null;
                obj        = null;
            }
        }
Esempio n. 3
0
        public bool UpdateGroups(int CompanyId, int EmpId, string jsonGroupDetails)
        {
            Common_Library.CommonFunctions comfun = new Common_Library.CommonFunctions();
            if (comfun.DeleteRecords(CompanyId, 47))
            {
                SqlConnection con = new SqlConnection();
                connection           = ConfigurationManager.ConnectionStrings[Constants.connection].ConnectionString;
                con.ConnectionString = connection;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                con.Open();
                using (SqlTransaction sqlTransaction = con.BeginTransaction())
                {
                    try
                    {
                        using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con, SqlBulkCopyOptions.Default, sqlTransaction))
                        {
                            //Set the database table name
                            sqlBulkCopy.DestinationTableName = AdminConstants.tblGroup;

                            //[OPTIONAL]: Map the DataTable columns with that of the database table
                            sqlBulkCopy.ColumnMappings.Add(AdminConstants.colGroupName, AdminConstants.colGroupName);
                            sqlBulkCopy.ColumnMappings.Add(AdminConstants.colCompanyId, AdminConstants.colCompanyId);
                            sqlBulkCopy.ColumnMappings.Add(AdminConstants.colDepartmentId, AdminConstants.colDepartmentId);
                            sqlBulkCopy.ColumnMappings.Add(AdminConstants.CreatedEmpID, AdminConstants.CreatedEmpID);
                            sqlBulkCopy.ColumnMappings.Add(AdminConstants.ModifiedEmpID, AdminConstants.ModifiedEmpID);
                            sqlBulkCopy.WriteToServer(comfun.StringtoDataTable(jsonGroupDetails));
                            sqlTransaction.Commit();
                        }
                        return(true);
                    }
                    catch (Exception e)
                    {
                        sqlTransaction.Rollback();
                        return(false);
                    }
                    finally
                    {
                        con.Close();
                        comfun = null;
                    }
                }
            }
            return(false);
        }
        public bool GetForgotPassword(string UserName, int Operation)
        {
            SqlConnection con = new SqlConnection();

            try
            {
                con                  = new SqlConnection();
                connection           = ConfigurationManager.ConnectionStrings[Constants.connection].ConnectionString;
                con.ConnectionString = connection;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = con;
                cmd.CommandText    = Constants.getLoginInfo;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 300;
                con.Open();
                cmd.Parameters.AddWithValue(Constants.paramUserName, UserName);
                cmd.Parameters.AddWithValue(Constants.ParamPassword, "");
                cmd.Parameters.AddWithValue(Constants.paramOperId, Operation);
                IDataReader dataReader = cmd.ExecuteReader();
                string      test       = "";
                while (dataReader.Read())
                {
                    string password = Convert.ToString(dataReader["Password"]);
                    Common_Library.CommonFunctions comfun = new Common_Library.CommonFunctions();
                    if (comfun.SendEmail(UserName, "", "", "Password for Login", "Your password for login is " + password +
                                         "<br /> Click the below link for login <br /><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>"))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                con.Close();
            }
        }
        public string CreateEmployee(string FirstName, string LastName, string Title, string EmployeeCode, int JobTitle, int Manager, string ProfilePicUrl,
                                     string QuotesPictureUrl, string BackGroundPicUrl, DateTime HireDate, DateTime ConfirmationDate, string WorkEMail, int OfficeLocation,
                                     string WorkLocation, int EmptTypeId, DateTime RelievingDate, int CompanyId, int FkEmpStatus, DateTime CreatedDate, DateTime ModifiedDate, int CreatedEmpId,
                                     int ModifiedEmpId, int WeekOffDays, string StartTime, string EndTime, string QuotesText)
        {
            SqlConnection con = new SqlConnection();

            try
            {
                connection = ConfigurationManager.ConnectionStrings[Constants.connection].ConnectionString;
                Dictionary <string, int> empData = new Dictionary <string, int>();
                con.ConnectionString = connection;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = con;
                cmd.CommandText    = Constants.setEmployeeInfo;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 300;
                con.Open();
                cmd.Parameters.AddWithValue(Constants.paramFirstName, FirstName);
                cmd.Parameters.AddWithValue(Constants.ParamLastName, LastName);
                cmd.Parameters.AddWithValue(Constants.paramTitle, Title);
                cmd.Parameters.AddWithValue(Constants.ParamEmployeeCode, EmployeeCode);
                cmd.Parameters.AddWithValue(Constants.paramJobTitle, JobTitle);
                cmd.Parameters.AddWithValue(Constants.ParamManager, Manager);
                cmd.Parameters.AddWithValue(Constants.paramProfilePicUrl, ProfilePicUrl);
                cmd.Parameters.AddWithValue(Constants.paramQuotesPictureUrl, QuotesPictureUrl);
                cmd.Parameters.AddWithValue(Constants.paramBackGroundPicUrl, BackGroundPicUrl);
                cmd.Parameters.AddWithValue(Constants.ParamHireDate, HireDate);
                cmd.Parameters.AddWithValue(Constants.paramConfirmationDate, ConfirmationDate);
                cmd.Parameters.AddWithValue(Constants.ParamWorkEmail, WorkEMail);
                cmd.Parameters.AddWithValue(Constants.paramOfficeLocation, OfficeLocation);
                cmd.Parameters.AddWithValue(Constants.ParamWorkLocation, WorkLocation);
                cmd.Parameters.AddWithValue(Constants.paramEmptTypeId, EmptTypeId);
                cmd.Parameters.AddWithValue(Constants.ParamRelievingDate, RelievingDate);
                cmd.Parameters.AddWithValue(Constants.paramCompanyId, CompanyId);
                cmd.Parameters.AddWithValue(Constants.paramFkEmpStatus, FkEmpStatus);
                cmd.Parameters.AddWithValue(Constants.ParamCreatedDate, CreatedDate);
                cmd.Parameters.AddWithValue(Constants.paramModifiedDate, ModifiedDate);
                cmd.Parameters.AddWithValue(Constants.ParamCreatedEmpID, CreatedEmpId);
                cmd.Parameters.AddWithValue(Constants.paramModifiedEmpID, ModifiedEmpId);
                cmd.Parameters.AddWithValue(Constants.paramWeekOffDays, WeekOffDays);
                cmd.Parameters.AddWithValue(Constants.ParamStartTime, StartTime);
                cmd.Parameters.AddWithValue(Constants.paramEndTime, EndTime);
                cmd.Parameters.AddWithValue(Constants.paramQuotesText, QuotesText);

                IDataReader dataReader = cmd.ExecuteReader();
                if (dataReader.Read())
                {
                    string toAddress  = dataReader[1].ToString();
                    string ccAddress  = dataReader[0].ToString();
                    string bccAddress = dataReader[1].ToString();
                    string subject    = "Portal Account Information";
                    string msgBody    = "UserName : "******"<br/>Password : "******"<br/> Link : <a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                    Common_Library.CommonFunctions comfun = new Common_Library.CommonFunctions();
                    if (comfun.SendEmail(toAddress, ccAddress, bccAddress, subject, msgBody))
                    {
                        empData.Add("EmpId", Convert.ToInt32(dataReader[3]));
                        empData.Add("MailStatus", 1);
                    }
                    else
                    {
                        empData.Add("EmpId", Convert.ToInt32(dataReader[3]));
                        empData.Add("MailStatus", 0);
                    }
                }
                else
                {
                    empData.Add("EmpId", 0);
                    empData.Add("MailStatus", 0);
                }
                return(JsonConvert.SerializeObject(empData, Formatting.Indented));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
        public bool SendEmail(IDataReader dataReader, int TypeValues, bool IsLeave)
        {
            try
            {
                bool   IsSuccess   = false;
                string toAddress   = string.Empty;
                string ccAddress   = string.Empty;
                string ReqType     = string.Empty;
                string Name        = string.Empty;
                string StartDate   = string.Empty;
                string EndDate     = string.Empty;
                string Requester   = string.Empty;
                string TaskStatus  = string.Empty;
                string taskName    = string.Empty;
                string projectName = string.Empty;
                while (dataReader.Read())
                {
                    IsSuccess = true;
                    if (Convert.ToString(dataReader["ToAddress"]) != string.Empty)
                    {
                        toAddress = toAddress + Convert.ToString(dataReader["ToAddress"]) + ",";
                    }
                    if (Convert.ToString(dataReader["ccAddress"]) != string.Empty)
                    {
                        ccAddress = ccAddress + Convert.ToString(dataReader["ccAddress"]) + ",";
                    }
                    if (Convert.ToString(dataReader["TypeName"]) != string.Empty)
                    {
                        ReqType = Convert.ToString(dataReader["TypeName"]);
                    }
                    if (Convert.ToString(dataReader["Name"]) != string.Empty)
                    {
                        Name = Convert.ToString(dataReader["Name"]);
                    }
                    if (IsLeave)
                    {
                        StartDate = Convert.ToString(dataReader["StartDate"]);
                        EndDate   = Convert.ToString(dataReader["EndDate"]);
                        Requester = Convert.ToString(dataReader["Requester"]);
                    }
                    if (TypeValues == 14)
                    {
                        if (Convert.ToString(dataReader["Status"]) != string.Empty)
                        {
                            TaskStatus = Convert.ToString(dataReader["Status"]);
                        }
                    }
                    else if (TypeValues == 13)
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(dataReader["TaskName"])))
                        {
                            taskName = Convert.ToString(dataReader["TaskName"]);
                        }
                        if (!string.IsNullOrEmpty(Convert.ToString(dataReader["ProjectName"])))
                        {
                            projectName = Convert.ToString(dataReader["ProjectName"]);
                        }
                    }
                    else if (TypeValues == 2 || TypeValues == 3 || TypeValues == 4)
                    {
                        Requester = Convert.ToString(dataReader["Requester"]);
                    }
                    else if (TypeValues >= 16 && TypeValues <= 19)
                    {
                        if (TypeValues != 16)
                        {
                            Requester = Convert.ToString(dataReader["Requester"]);
                        }
                        StartDate = Convert.ToString(dataReader["CompOffFor"]);      //Comp Off For
                        EndDate   = Convert.ToString(dataReader["RequestedToDate"]); //Comp Off Requested date
                    }
                }
                if (IsSuccess)
                {
                    string bccAddress = string.Empty;
                    string subject = string.Empty, msgBody = string.Empty;
                    ccAddress = ccAddress.TrimEnd(',');
                    if (TypeValues == 11 && !string.IsNullOrEmpty(ccAddress))
                    {
                        toAddress = toAddress + ccAddress;
                        ccAddress = string.Empty;
                    }
                    toAddress = toAddress.TrimEnd(',');

                    switch (TypeValues)
                    {
                    case 1:
                        subject = "Request for " + ReqType;
                        if (IsLeave)
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Name + " for " + ReqType + " from " + StartDate + " to " + EndDate + " is waiting for your approval.<br />" +
                                      "Click the below link to open the ticket<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        }
                        else
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Name + " for " + ReqType + " is waiting for your approval.<br />" +
                                      "Click the below link to open the ticket<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        }
                        break;

                    case 2:
                        subject = "Request for " + ReqType + " was Approved";
                        if (IsLeave)
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " from " + StartDate + " to " + EndDate + " was Approved by " + Name;
                        }
                        else
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " was Approved by " + Name;
                        }
                        break;

                    case 3:
                        subject = "Request for " + ReqType + " was Rejected";
                        if (IsLeave)
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " from " + StartDate + " to " + EndDate + " was Rejected by " + Name;
                        }
                        else
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " was Rejected by " + Name;
                        }
                        break;

                    case 4:
                        subject = "Request for " + ReqType + " was cancelled";
                        if (IsLeave)
                        {
                            msgBody = "Hi,<br/><br/>Request for " + ReqType + " from " + StartDate + " to " + EndDate + " was cancelled by " + Requester;
                        }
                        else
                        {
                            msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " was successfully cancelled.";
                        }
                        break;

                    case 5:
                        subject = "New Announcement";
                        msgBody = "Hi,<br/><br/>An Announcement has been added to the portal.<br/>" +
                                  "Click the below link to view the Announcement<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 6:
                        subject = "New Event";
                        msgBody = "Hi,<br/><br/>An Event has been added to the portal.<br/>" +
                                  "Click the below link to view the Event<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 7:
                        subject = "Update Event";
                        msgBody = "Hi,<br/><br/>An Event has been updated in the portal.<br/>" +
                                  "Click the below link to view the Event<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 8:
                        subject = "Cancel Event";
                        msgBody = "Hi,<br/><br/>An Event has been cancelled from the portal.<br/>" +
                                  "Click the below link to view the Event<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 9:
                        subject = "New Opening";
                        msgBody = "Hi,<br/><br/>An Opening has been added to the portal.<br/>" +
                                  "Click the below link to view the Opening<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 10:
                        subject = "New Training";
                        msgBody = "Hi,<br/><br/>A Training has been added to the portal.<br/>" +
                                  "Click the below link to view the Training<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 11:
                        subject = "New Document";
                        msgBody = "Hi,<br/><br/>A Document has been added to the portal.<br/>" +
                                  "Click the below link to view the Document <br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 12:
                        subject = "New Task";
                        msgBody = "Hi,<br/><br/>A Task has been added to the portal.<br/>" +
                                  "Click the below link to view the Task<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 13:
                        subject = "Task Update";
                        msgBody = "Hi,<br/><br/>A Task has been updated in the portal.<br/>" +
                                  "<b>Project Name : </b>" + projectName + "<br/>" +
                                  "<b>Task Name : </b>" + taskName + "<br/><br/>" +
                                  "Click the below link to view the Task details<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 14:
                        subject = "Task Status Update";
                        msgBody = "Hi,<br/><br/>" + Name + " changed the Task Status for <b>" + ReqType + "</b> to <b>" + TaskStatus + "</b><br/>" +
                                  "Click the below link to view the Task<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 15:
                        subject = "New candidate has been added";
                        msgBody = "Hi,<br/><br/> New candidate has been added to the candidate table.<br/><br/>" +
                                  "Click the below link to view the candidate<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 16:
                        subject = "Request for " + ReqType;
                        msgBody = "Hi,<br/><br/>Request from " + Name + " for " + ReqType + " on " + EndDate + " for working/worked on " +
                                  StartDate + " is waiting for your approval.<br />" +
                                  "Click the below link to open the ticket<br/><a href='http://portal.nuvento.com/'>http://portal.nuvento.com/</a>";
                        break;

                    case 17:
                        subject = "Request for " + ReqType + " was Approved";
                        msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " on " + EndDate + " for working/worked on " +
                                  StartDate + " was Approved by " + Name;

                        break;

                    case 18:
                        subject = "Request for " + ReqType + " was Rejected";
                        msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " on " + EndDate + " for working/worked on " +
                                  StartDate + " was Rejected by " + Name;
                        break;

                    case 19:
                        subject = "Request for " + ReqType + " was cancelled";
                        msgBody = "Hi,<br/><br/>Request from " + Requester + " for " + ReqType + " on " + EndDate + " for working/worked on " +
                                  StartDate + " was successfully cancelled";
                        break;
                    }
                    Common_Library.CommonFunctions comfun = new Common_Library.CommonFunctions();
                    if (comfun.SendEmail(toAddress, ccAddress, bccAddress, subject, msgBody))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }