Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetCount(BaseRequest request)
        {
            if (!ModelState.IsValid || request == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            try
            {
                var result = await Task.Factory.StartNew(() => NeeoVoipApi.GetMcrCount(request.Uid));

                return(Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, string>()
                {
                    { "GetMcrCountResult", result }
                }));
            }
            catch (ApplicationException applicationException)
            {
                return(SetCustomResponseMessage("", (HttpStatusCode)(Convert.ToInt32(applicationException.Message))));
            }
            catch (Exception exception)
            {
                LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 2
0
        public string GetMcrCount(string userID)
        {
            userID = (userID != null) ? userID.Trim() : userID;
            //         #region Verify User
            //var request = OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
            //string keyFromClient = request.Headers["key"];
            //   if (NeeoUtility.AuthenticateUserRequest( userID, keyFromClient))
            //{
            //#endregion

            ulong temp;

            if (!NeeoUtility.IsNullOrEmpty(userID) && ulong.TryParse(userID, out temp))
            {
                try
                {
                    return(NeeoVoipApi.GetMcrCount(userID));
                }
                catch (ApplicationException applicationException)
                {
                    NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(applicationException.Message)));
                }
                catch (Exception exception)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
                    NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.UnknownError);
                }
                return("");
            }
            else
            {
                NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments);
                return("");
            }
            //}
            //   else
            //   {
            //       NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)HttpStatusCode.Unauthorized);
            //       return "";
            //   }
        }
Ejemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var _conStr = ConfigurationManager.ConnectionStrings["neeoConnectionString"].ConnectionString;
            var _con    = new SqlConnection(_conStr);

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "Select username from neUserExtension where devicePlatform = 1";
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = _con;

                System.Data.DataTable dtContactsInfo = new System.Data.DataTable();
                SqlDataAdapter        adapter        = new SqlDataAdapter(cmd);
                adapter.Fill(dtContactsInfo);

                if (dtContactsInfo.Rows.Count > 0)
                {
                    Response.Write("Count == > " + dtContactsInfo.Rows.Count.ToString() + "<br/>");
                    for (int i = 0; i < dtContactsInfo.Rows.Count; i++)
                    {
                        try
                        {
                            var mcr = NeeoVoipApi.GetMcrCount(dtContactsInfo.Rows[i]["username"].ToString());

                            Response.Write(i + " ==> " + dtContactsInfo.Rows[i]["username"].ToString() + " ==> " + mcr + "<br/>");
                            var        _conStrr = ConfigurationManager.ConnectionStrings["neeoConnectionString"].ConnectionString;
                            var        _conn    = new SqlConnection(_conStrr);
                            SqlCommand cmdd     = new SqlCommand();
                            cmdd.CommandText = "UPDATE [dbo].[neOfflineUserMessageCount] SET [mcrCount] = " + mcr + "  WHERE username  = '******'";
                            cmdd.CommandType = CommandType.Text;
                            cmdd.Connection  = _conn;

                            using (_conn)
                            {
                                _conn.Open();
                                cmdd.ExecuteNonQuery();
                                _conn.Close();
                                Response.Write(i + " ==> " + dtContactsInfo.Rows[i]["username"].ToString() + " ==>  updated" + "<br/>");
                            }
                        }
                        catch (SqlException sqlEx)
                        {
                            Response.Write(sqlEx.Message + "<br/>");
                        }
                        catch (ApplicationException applicationException)
                        {
                            Response.Write(applicationException.Message + "<br/>");
                        }
                        catch (Exception exception)
                        {
                            Response.Write(exception.Message + "<br/>");
                        }
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                Response.Write(sqlEx.Message + "<br/>");
            }
            catch (Exception Ex)
            {
                Response.Write(Ex.Message + "<br/>");
            }
            finally
            {
                if (_con.State != ConnectionState.Closed)
                {
                    _con.Close();
                }
            }
        }