Пример #1
0
        public JsonResult StartConsumer(FormCollection collection)
        {
            List <Contain> tasklist = HttpContext.Application["TaskList"] as List <Contain>;

            if (tasklist != null)
            {
                string key  = collection["key"];
                string pkey = collection["pkey"];

                ProfileBL   pbl     = new ProfileBL();
                CoreProfile profile = pbl.GetProfile(pkey);

                switch (key)
                {
                case "system":
                    for (int i = 0; i < profile.SystemConsumerNum; i++)
                    {
                        CreateConsumer("mq_system_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveSystem));
                    }
                    break;

                case "operate":
                    for (int i = 0; i < profile.OperateConsumerNum; i++)
                    {
                        CreateConsumer("mq_operate_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveOperate));
                    }
                    break;

                case "exception":
                    for (int i = 0; i < profile.ExceptionConsumerNum; i++)
                    {
                        CreateConsumer("mq_exception_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveException));
                    }
                    break;

                case "normal":
                    for (int i = 0; i < profile.NormalConsumerNum; i++)
                    {
                        CreateConsumer("mq_normal_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveNormal));
                    }
                    break;
                }
            }

            return(Json(new ResultDTO()
            {
                Status = "Success",
                Message = "",
                Data = ""
            }));
            //
        }
Пример #2
0
        // GET: Core/Edit/5
        public ActionResult Edit(string key)
        {
            CoreProfile profile = null;

            if (!string.IsNullOrEmpty(key))
            {
                ProfileBL bl = new ProfileBL();

                profile = bl.GetProfile(key);
            }

            return(View("ProfileDetail", profile));
        }
Пример #3
0
        public HttpResponseMessage GetProfile(HttpRequestMessage request)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token);

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        ProfileEN userProfile = profileBL.GetProfile(personVerified.PersonID);

                        if (userProfile != null)
                        {
                            ProfileResponse profileResponse = interactor.CreateProfileResponse(userProfile);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, profileResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization oken must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
Пример #4
0
        // POST: Core/Delete/5

        public ActionResult Delete(string key)
        {
            ProfileBL bl = new ProfileBL();

            CoreProfile profile = bl.GetProfile(key);

            StopConsumer(profile.ProjectKey, null);

            bl.RemoveProfile(key);


            List <CoreProfile> profiles = bl.GetProfileList();

            return(View("Profiles", profiles));
        }
Пример #5
0
        public JsonResult RemoveConsumer(FormCollection collection)
        {
            string profileKey = collection["pkey"];
            string key        = collection["key"];

            ProfileBL   bl      = new ProfileBL();
            CoreProfile profile = bl.GetProfile(profileKey);

            StopConsumer(profile.ProjectKey, key);


            return(Json(new ResultDTO()
            {
                Status = "Success",
                Message = "",
                Data = ""
            }, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public ActionResult InitProfile(string key)
        {
            try
            {
                ProfileBL bl = new ProfileBL();

                CoreProfile profile = bl.GetProfile(key);


                StopConsumer(profile.ProjectKey, null);

                CreateMQ(profile);

                InitHeartData(profile.ProjectKey);

                string[] types = Enum.GetNames(typeof(LogType));

                foreach (string type in types)
                {
                    switch (type)
                    {
                    case "ExceptionLog":

                        for (int i = 0; i < profile.ExceptionConsumerNum; i++)
                        {
                            CreateConsumer("mq_exception_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveException));
                        }

                        break;

                    case "OperateLog":

                        for (int i = 0; i < profile.OperateConsumerNum; i++)
                        {
                            CreateConsumer("mq_operate_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveOperate));
                        }

                        break;

                    case "SystemLog":

                        for (int i = 0; i < profile.SystemConsumerNum; i++)
                        {
                            CreateConsumer("mq_system_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveSystem));
                        }

                        break;

                    case "Normal":

                        for (int i = 0; i < profile.NormalConsumerNum; i++)
                        {
                            CreateConsumer("mq_normal_" + profile.ProjectKey, profile.MQServer, profile.ProjectKey, i, new EventHandler <BasicDeliverEventArgs>(new TrackLogBL(SendHeartData).ResolveNormal));
                        }

                        break;
                    }
                }


                List <CoreProfile> profiles = bl.GetProfileList();

                return(View("Profiles", profiles));
            }
            catch (Exception e)
            {
                return(View("Profiles"));
            }
        }