public ResponseModel StoreLoggedInAccountDetails()
        {
            LoggedInAgentModel loggedinAccInfo = null;
            ResponseModel      objResponseModel = new ResponseModel();
            int            statusCode = 0; string statusMessage = "";
            StoreDashboard storeDashboard = new StoreDashboard();

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                var folderName = Path.Combine(_profileImg_Resources, StoreProfileImage);
                var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);

                loggedinAccInfo = storeDashboard.GetLogginAccountInfo(new StoreDashboardService(_connectioSting),
                                                                      authenticate.TenantId, authenticate.UserMasterID, pathToSave);

                statusCode                    = loggedinAccInfo != null ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound;
                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = loggedinAccInfo != null ? loggedinAccInfo : null;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
예제 #2
0
        public LoggedInAgentModel GetLogginAccountInfo(int tenantID, int UserID, string ProfilePicPath)
        {
            DataSet            ds = new DataSet();
            DateTime           now = DateTime.Now; DateTime temp = new DateTime();
            TimeSpan           diff         = new TimeSpan();
            MySqlCommand       cmd          = new MySqlCommand();
            LoggedInAgentModel loggedInAcc  = new LoggedInAgentModel();
            ChatStatus         chatstat     = new ChatStatus();
            string             profileImage = string.Empty;
            int ShiftDuration = 0;

            try
            {
                conn           = Db.Connection;
                cmd.Connection = conn;

                loggedInAcc.AgentId = UserID;
                //loggedInAcc.AgentName = AccountName;
                //loggedInAcc.AgentEmailId = EmailID;

                MySqlCommand cmd1 = new MySqlCommand("SP_LoggedInAccountInformation", conn);
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.Parameters.AddWithValue("_tenantID", tenantID);
                cmd1.Parameters.AddWithValue("_userID", UserID);

                MySqlDataAdapter da = new MySqlDataAdapter();
                da.SelectCommand = cmd1;
                da.Fill(ds);

                if (ds != null && ds.Tables.Count > 0)
                {
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        loggedInAcc.LoginTime    = ds.Tables[0].Rows[0]["logintime"] != System.DBNull.Value ? Convert.ToDateTime(ds.Tables[0].Rows[0]["logintime"]).ToString("h:mm tt", culture) : "";
                        loggedInAcc.LogoutTime   = ds.Tables[0].Rows[0]["logouttime"] != System.DBNull.Value ? Convert.ToDateTime(ds.Tables[0].Rows[0]["logouttime"]).ToString("h:mm tt", culture) : "";
                        loggedInAcc.AgentName    = ds.Tables[0].Rows[0]["AccountName"] != System.DBNull.Value ? Convert.ToString(ds.Tables[0].Rows[0]["AccountName"]) : string.Empty;
                        loggedInAcc.AgentEmailId = ds.Tables[0].Rows[0]["EmailID"] != System.DBNull.Value ? Convert.ToString(ds.Tables[0].Rows[0]["EmailID"]) : string.Empty;

                        ShiftDuration = ds.Tables[0].Rows[0]["ShiftDuration"] != System.DBNull.Value ? Convert.ToInt32(ds.Tables[0].Rows[0]["ShiftDuration"]) : 0;
                        profileImage  = ds.Tables[0].Rows[0]["ProfilePicture"] != System.DBNull.Value ? Convert.ToString(ds.Tables[0].Rows[0]["ProfilePicture"]) : string.Empty;


                        loggedInAcc.ProfilePicture = !string.IsNullOrEmpty(profileImage) ? Path.Combine(ProfilePicPath, profileImage) : string.Empty;
                        if (ShiftDuration > 0)
                        {
                            temp = temp.AddHours(ShiftDuration);
                            loggedInAcc.ShiftDurationInHour    = temp.Hour;
                            loggedInAcc.ShiftDurationInMinutes = temp.Minute;
                        }

                        if (!string.IsNullOrEmpty(loggedInAcc.LoginTime))
                        {
                            diff = now - Convert.ToDateTime(ds.Tables[0].Rows[0]["logintime"]);
                            loggedInAcc.LoggedInDuration          = Math.Abs(diff.Hours) + "H " + Math.Abs(diff.Minutes) + "M";
                            loggedInAcc.LoggedInDurationInHours   = Math.Abs(diff.Hours);
                            loggedInAcc.LoggedInDurationInMinutes = Math.Abs(diff.Minutes);

                            chatstat.isOnline = true;
                        }
                        else
                        {
                            loggedInAcc.LoggedInDuration = "0 H 0 M";
                            chatstat.isOffline           = true;
                        }

                        loggedInAcc.Chatstatus = chatstat;
                    }
                    if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                    {
                        loggedInAcc.SLAScore        = ds.Tables[1].Rows[0]["SLAScore"] != System.DBNull.Value ? Convert.ToString(ds.Tables[1].Rows[0]["SLAScore"]) : string.Empty;
                        loggedInAcc.AvgResponseTime = ds.Tables[1].Rows[0]["AverageResponseTime"] != System.DBNull.Value ? Convert.ToString(ds.Tables[1].Rows[0]["AverageResponseTime"]) : string.Empty;
                        loggedInAcc.CSATScore       = ds.Tables[1].Rows[0]["CSATScore"] != System.DBNull.Value ? Convert.ToString(ds.Tables[1].Rows[0]["CSATScore"]) : string.Empty;
                    }

                    if (ds.Tables[2] != null && ds.Tables[2].Rows.Count > 0)
                    {
                        loggedInAcc.WorkTimeInPercentage = Convert.ToString(ds.Tables[2].Rows[0]["WorkTimeInPercentage"]);
                        loggedInAcc.TotalWorkingTime     = Convert.ToString(ds.Tables[2].Rows[0]["TotalWorkingTime"]);
                        loggedInAcc.workingMinute        = Convert.ToString(ds.Tables[2].Rows[0]["workingMinute"]);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = Convert.ToString(ex.InnerException);
                throw ex;
            }
            finally
            {
                if (ds != null)
                {
                    ds.Dispose();
                }
            }

            return(loggedInAcc);
        }