public bool IsCurrentUserImpersonatingProgramManagerOnProject(int idProject, int idAssociate, int idImpersonated)
        {
            bool       result  = false;
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authIsAssociateKeyUserImpersonatingManagerOnProject";

            SqlParameter idProjectPar = new SqlParameter("@IdProject", idProject);

            idProjectPar.DbType    = DbType.Int32;
            idProjectPar.Direction = ParameterDirection.Input;
            command.Parameters.Add(idProjectPar);

            SqlParameter idAssociatePar = new SqlParameter("@IdAssociate", idAssociate);

            idAssociatePar.DbType    = DbType.Int32;
            idAssociatePar.Direction = ParameterDirection.Input;
            command.Parameters.Add(idAssociatePar);

            SqlParameter idImpersonatedPar = new SqlParameter("@IdImpersonated", idImpersonated);

            idImpersonatedPar.DbType    = DbType.Int32;
            idImpersonatedPar.Direction = ParameterDirection.Input;
            command.Parameters.Add(idImpersonatedPar);

            result = Convert.ToBoolean(CurrentConnectionManager.ExecuteScalar(command));
            return(result);
        }
        /// <summary>
        /// Gets information about the user, if his inergy login exists in the database
        /// </summary>
        /// <param name="InergyLogin">the inergy login of the user</param>
        /// <returns>a DataTable containing one row with information about the user, or an empty datatable if the user
        /// does not have a valid inergy login</returns>
        public DataTable GetUserDetails(string inergyLogin, int idCountry)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authVerifyLogin";

            SqlParameter inergyLoginParameter = new SqlParameter("@InergyLogin", inergyLogin);

            inergyLoginParameter.DbType    = DbType.String;
            inergyLoginParameter.Direction = ParameterDirection.Input;

            SqlParameter idCountryParameter;

            if (idCountry == ApplicationConstants.INT_NULL_VALUE)
            {
                idCountryParameter = new SqlParameter("@IdCountry", DBNull.Value);
            }
            else
            {
                idCountryParameter = new SqlParameter("@IdCountry", idCountry);
            }
            idCountryParameter.DbType    = DbType.Int32;
            idCountryParameter.Direction = ParameterDirection.Input;

            command.Parameters.Add(inergyLoginParameter);
            command.Parameters.Add(idCountryParameter);
            return(CurrentConnectionManager.GetDataTable(command));
        }
Example #3
0
        public DataSet SelectObjectForDisplay(IGenericEntity ent)
        {
            this.storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey("SelectObjectForDisplay"))
            {
                throw new NotImplementedException(ApplicationMessages.EXCEPTION_IMPLEMENT_SELECTOBJECT);
            }

            DBStoredProcedure selectSP = storedProcedures["SelectObjectForDisplay"];
            SqlCommand        cmd      = selectSP.GetSqlCommand();

            DataSet returnDS = null;

            try
            {
                returnDS = CurrentConnectionManager.GetDataSet(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(returnDS);
        }
Example #4
0
        /// <summary>
        /// 停止
        /// </summary>
        public void Stop()
        {
            if (IsWorking)
            {
                IsWorking = false;

                Utility.Debuger.DebugLog("Socket Server:Stoping....");
                CurrentConnectionManager.Each((client) =>
                {
                    //服务器关闭
                    DisConnectClient(client, 0);
                    return(false);
                });
                CurrentConnectionManager.Clear();

                MREvent.Set();
                SendMREvent.Set();
                AcceptThread.Join();
                SendThread.Join();
                SendThread   = null;
                AcceptThread = null;
                _socket.Close();
                _socket = null;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ent"></param>
        public DataTable GetAsscoiateRoles()
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authSelectProfile";
            return(CurrentConnectionManager.GetDataTable(command));
        }
Example #6
0
        /// <summary>
        /// Inserts all work selected work packages (wppreselection screen) into temp table ##BUDGET_PRESELECTION_TEMP
        /// </summary>
        /// <param name="commandText"></param>
        public void BulkInsert(string commandText)
        {
            SqlCommand bulkInsertCommand = new SqlCommand();

            bulkInsertCommand.CommandType = CommandType.Text;
            bulkInsertCommand.CommandText = commandText;
            CurrentConnectionManager.ExecuteTextCommand(bulkInsertCommand);
        }
        /// <summary>
        /// Gets information about the projects that this user is part of
        /// </summary>
        /// <param name="idCurrentUser">the id of the current user</param>
        /// <returns>A DataTable containing information about the projects that this user is part of</returns>
        public DataTable GetUserProjects(int idCurrentUser)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authSelectUserProjects";
            SqlParameter idCurrentUserParameter = new SqlParameter("@IdUser", idCurrentUser);

            idCurrentUserParameter.DbType    = DbType.Int32;
            idCurrentUserParameter.Direction = ParameterDirection.Input;
            command.Parameters.Add(idCurrentUserParameter);
            return(CurrentConnectionManager.GetDataTable(command));
        }
        public DataTable GetAssociateRole(int idAssociate)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authSelectRoles";

            SqlParameter idAssociateParameter = new SqlParameter("@IdAssociate", idAssociate);

            idAssociateParameter.DbType    = DbType.Int32;
            idAssociateParameter.Direction = ParameterDirection.Input;
            command.Parameters.Add(idAssociateParameter);
            return(CurrentConnectionManager.GetDataTable(command));
        }
        public DataTable GetUserCountries(string inergyLogin)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authSelectUserCountries";

            SqlParameter inergyLoginParameter = new SqlParameter("@InergyLogin", inergyLogin);

            inergyLoginParameter.DbType    = DbType.String;
            inergyLoginParameter.Direction = ParameterDirection.Input;
            command.Parameters.Add(inergyLoginParameter);

            return(CurrentConnectionManager.GetDataTable(command));
        }
        /// <summary>
        /// method used to retrieve user settings from database
        /// </summary>
        /// <param name="associateId"></param>
        public DataTable usrSelectUserSettings(int associateId)
        {
            DataTable dt = new DataTable();

            try
            {
                SqlCommand cmd = new SqlCommand("usrSelectUserSettings");
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@AssociateId", SqlDbType.Int).Value = associateId;
                dt = CurrentConnectionManager.GetDataTable(cmd);
            }
            catch (SqlException ex)
            {
                throw new IndException(ex);
            }
            return(dt);
        }
        /// <summary>
        /// Updates or inserts a new associate to a role
        /// </summary>
        /// <param name="idAssociate">the id of the associate</param>
        /// <param name="idRole">the id of the role</param>
        /// <returns>the number of affected rows (should be 1   )</returns>
        public int SaveAssociateRole(int idAssociate, int idRole)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "authUpdateAssociateRole";

            SqlParameter idAssociateParameter = new SqlParameter("@IdAssociate", idAssociate);

            idAssociateParameter.DbType    = DbType.Int32;
            idAssociateParameter.Direction = ParameterDirection.Input;
            command.Parameters.Add(idAssociateParameter);

            SqlParameter idRoleParameter = new SqlParameter("@IdRole", idRole);

            idRoleParameter.DbType    = DbType.Int32;
            idRoleParameter.Direction = ParameterDirection.Input;
            command.Parameters.Add(idRoleParameter);

            return(CurrentConnectionManager.ExecuteStoredProcedure(command));
        }
        /// <summary>
        /// method used to update user settings
        /// </summary>
        /// <param name=""></param>
        /// <returns>return true if operation succeded</returns>
        public bool usrInsertOrUpdateUserSettings(IUserSettings userSettings)
        {
            int returnValue;

            try
            {
                SqlCommand cmd = new SqlCommand("usrInsertOrUpdateUserSettings");
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@AssociateId", SqlDbType.Int).Value            = userSettings.AssociateId;
                cmd.Parameters.Add("@AmountScaleOption", SqlDbType.Int).Value      = userSettings.AmountScaleOption;
                cmd.Parameters.Add("@NumberOfRecordsPerPage", SqlDbType.Int).Value = userSettings.NumberOfRecordsPerPage;
                cmd.Parameters.Add("@CurrencyRepresentation", SqlDbType.Int).Value = userSettings.CurrencyRepresentation;

                returnValue = CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException ex)
            {
                throw new IndException(ex);
            }
            return(returnValue == 1);
        }
Example #13
0
 private void OnAccpet(IAsyncResult ar)
 {
     MREvent.Set();
     if (IsWorking)
     {
         Socket server = (Socket)ar.AsyncState;
         Socket client = server.EndAccept(ar);
         if (client != null)
         {
             client.NoDelay = true;
             if (CurrentConnectionManager.Count >= MaxClient)
             {
                 try
                 {
                     client.Close();
                 }
                 finally
                 {
                 }
             }
             else
             {
                 var nClient = CurrentConnectionManager.CreateClient(client, this);
                 try
                 {
                     nClient.Socket.BeginReceive(nClient.Buffer, 0,
                                                 nClient.Buffer.Length,
                                                 SocketFlags.None,
                                                 new AsyncCallback(OnDataReceived), nClient);
                     OnConnect(nClient);
                 }
                 catch (Exception ex)
                 {
                     HandleException(nClient, ex);
                 }
             }
         }
     }
 }
Example #14
0
        public void Start()
        {
            OnStart();
            IsWorking = true;
            CurrentConnectionManager.Clear();
            _socket = new Socket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            //_socket.SendTimeout = 999;
            //_socket.ReceiveTimeout = 999;
            _socket.LingerState = new LingerOption(true, 10);
            _socket.Bind(new IPEndPoint(IPAddress.Any, Port));
            _socket.Listen(2000);

            AcceptThread = new Thread(new ThreadStart(ThreadRun));
            AcceptThread.IsBackground = true;
            AcceptThread.Start();

            SendThread = new Thread(new ThreadStart(SendMessage));
            SendThread.IsBackground = true;
            SendThread.Start();

            Debuger.DebugLog("Server Listen at port:" + Port);
        }
Example #15
0
 private bool HaveClient(Client client)
 {
     return(CurrentConnectionManager.Exisit(client));
 }
Example #16
0
 private void RemoveClient(Client client)
 {
     client.Close();
     CurrentConnectionManager.RemoveClient(client);
     OnCloseConnection(client);
 }