public CentralConnectCode CreateAndSendMetrics(MetricsEnhancement metricsEnhancement)
        {
            //Client
            ClientAction clientAction = new ClientAction(this.ConnectString);
            List<Client> clients = clientAction.RetrieveClientByClientNameAndDomain(metricsEnhancement.ClientName, metricsEnhancement.Domain);
            if (clients.Count != 1)
            {
                return CentralConnectCode.ClientNotFound;
            }
            Logger.Write("Client", clients[0]);
            Client client = clients[0];
            //Contact
            ContactAction contactAction = new ContactAction(this.ConnectString);
            List<Contact> primaryContacts = contactAction.RetrieveContactByFullName(client.PrimaryContact);
            if (primaryContacts.Count != 1)
            {
                return CentralConnectCode.PrimaryContactNotFound;
            }
            Logger.Write("Retrieve PrimaryContacts", primaryContacts[0]);
            Contact primaryContact = primaryContacts[0];
            List<Contact> secondaryContacts = contactAction.RetrieveContactByFullName(client.SecondaryContact);
            if (secondaryContacts.Count != 1)
            {
                return CentralConnectCode.SecondaryContactNotFound;
            }
            Logger.Write("Retrieve SecondaryContact", secondaryContacts[0]);
            Contact secondaryContact = secondaryContacts[0];
            //Company
            CompanyAction companyAction = new CompanyAction(this.ConnectString);
            List<Company> companys = companyAction.RetrieveCompanyByCompanyName(client.CompanyName);
            if (companys.Count != 1)
            {
                return CentralConnectCode.CompanyNotFound;
            }
            Logger.Write("Retrieve Company", companys[0]);
            Company company = companys[0];
            //registerClientMessages
            List<RegisterClientMessage> registerClientMessages = this.RetrieveRegisterClientMessageByEnvironmentAndClientNameAndDomain(metricsEnhancement.Environment, metricsEnhancement.ClientName, metricsEnhancement.Domain);
            if (registerClientMessages.Count != 1)
            {
                return CentralConnectCode.RegisterClientMessageNotExist;
            }
            Logger.Write("Retrieve registerClientMessages", registerClientMessages[0]);
            RegisterClientMessage registerClientMessage = registerClientMessages[0];
            //devices
            List<Device> devices = this.RetrieveRegisterDeviceByEnvironmentAndClientNameAndClientDomain(metricsEnhancement.Environment, metricsEnhancement.ClientName, metricsEnhancement.Domain);
            if (devices.Count == 0)
            {
                return CentralConnectCode.ClientNotFoundAssociatedDevice;
            }
            Logger.Write("Retrieve devices", devices);

            MetricsRequest metricsRequest = new MetricsRequest();
            //ClientInformation
            ClientInformation clientInformation = new ClientInformation();
            clientInformation.ClientName = metricsEnhancement.ClientName;
            clientInformation.Domain = metricsEnhancement.Domain;
            clientInformation.ProductNumber = client.ProductNumber;
            clientInformation.SerialNumber = client.SerialNumber;
            clientInformation.CoreSystemModel = client.CoreSystemModel;
            clientInformation.MAC = client.MAC;
            clientInformation.OSName = client.OSName;
            clientInformation.OSVersion = client.OSVersion;
            clientInformation.IPAddress = client.IPAddress;
            clientInformation.HPPID = registerClientMessage.HPPID;
            clientInformation.Password = registerClientMessage.Password;
            clientInformation.CSID = registerClientMessage.CSID;
            clientInformation.OSGDID = registerClientMessage.OSGDID;
            clientInformation.HWGDID = registerClientMessage.HWGDID;
            clientInformation.RegistrationToken = registerClientMessage.RegistrationToken;
            clientInformation.CompanyName = client.CompanyName;
            clientInformation.CountryCode = company.CountryCode;
            clientInformation.StateProvince = company.StateProvince;
            clientInformation.City = company.City;
            clientInformation.Street = company.Street;
            clientInformation.PostalCode = company.PostalCode;
            clientInformation.PrimaryContact = client.PrimaryContact;
            clientInformation.PrimaryFirstName = primaryContact.FirstName;
            clientInformation.PrimaryLastName = primaryContact.LastName;
            clientInformation.PrimaryEmailAddress = primaryContact.EmailAddress;
            clientInformation.PrimaryPhone = primaryContact.Phone;
            clientInformation.SecondaryContact = client.SecondaryContact;
            clientInformation.SecondaryFirstName = secondaryContact.FirstName;
            clientInformation.SecondaryLastName = secondaryContact.LastName;
            clientInformation.SecondaryEmailAddress = secondaryContact.EmailAddress;
            clientInformation.SecondaryPhone = secondaryContact.Phone;
            clientInformation.SupportPartnerId = metricsEnhancement.SupportPartnerId;
            clientInformation.ServicePartnerId = metricsEnhancement.ServicePartnerId;
            metricsRequest.ClientInformation = clientInformation;
            //deviceinformation
            DeviceAction deviceAction = new DeviceAction(this.ConnectString);
            List<DeviceInformation> deviceInformations = new List<DeviceInformation>();
            foreach (Device item in devices)
            {
                DeviceInformation deviceInformation = new DeviceInformation();
                deviceInformation.ClientName = client.ClientName;
                deviceInformation.ClientDomain = client.Domain;
                deviceInformation.DeviceName = item.DeviceName;
                deviceInformation.Domain = item.Domain;
                deviceInformation.ProductNumber = item.ProductNumber;
                deviceInformation.SerialNumber = item.SerialNumber;
                deviceInformation.CoreSystemModel = item.CoreSystemModel;
                deviceInformation.MAC = item.MAC;
                deviceInformation.OSName = item.OSName;
                deviceInformation.OSVersion = item.OSVersion;
                deviceInformation.IPAddress = item.IPAddress;
                List<RegisterDeviceMessage> registerDeviceMessages = deviceAction.RetrieveRegisterDeviceMessageByEnvironmentAndDeviceNameAndDomain(metricsEnhancement.Environment, item.DeviceName, item.Domain);
                if (registerDeviceMessages.Count != 1)
                {
                    return CentralConnectCode.RegisterDeviceMessageNotExist;
                }
                RegisterDeviceMessage registerDeviceMessage = registerDeviceMessages[0];
                deviceInformation.OSGDID = registerDeviceMessage.OSGDID;
                deviceInformation.OSGDIDUsn = registerDeviceMessage.OSGDIDUsn;
                deviceInformation.HWGDID = registerDeviceMessage.HWGDID;
                deviceInformation.HWGDIDUsn = registerDeviceMessage.HWGDIDUsn;
                deviceInformation.CollectionProblem = registerDeviceMessage.CollectionProblem;
                deviceInformation.MonitoringProblem = registerDeviceMessage.MonitoringProblem;
                deviceInformations.Add(deviceInformation);
            }
            metricsRequest.DeviceInformations = deviceInformations;
            //enhancementArguments
            Dictionary<string, string> enhancementArguments = new Dictionary<string, string>();
            if (metricsEnhancement.Arguments != null)
            {
                foreach (Argument item in metricsEnhancement.Arguments)
                {
                    if (!enhancementArguments.ContainsKey(item.key))
                    {
                        enhancementArguments.Add(item.key, item.value);
                    }
                }
            }
            metricsRequest.EnhancementArguments = enhancementArguments;
            //InvokeMetrics Plugin
            EnhancementAction enhancementAction = new EnhancementAction(this.ConnectString);
            PluginResponse result = enhancementAction.InvokeMetrics(metricsRequest,metricsEnhancement.Type);
            if (!result.IsSuccess)
            {
                Logger.Write("CreateMetricsFail-" + result.Message);
                return CentralConnectCode.CreateMetricsFail;
            }
            //SendMetrics
            DictionaryAction dictionaryAction = new DictionaryAction(this.ConnectString);
            string serviceUrl = string.Format("{0}/{1}", dictionaryAction.RetrieveServiceUrl(metricsEnhancement.Environment), "DataPackageReceiver/DataPackageReceiver.asmx");
            DataPackageSubmissionResult dataPackageSubmissionResult =this.SendMetricsRequest(serviceUrl,
                registerClientMessage.CSID,
                registerClientMessage.HWGDID,
                registerClientMessage.OSGDID,
                registerClientMessage.RegistrationToken,
                result.FileName,
                result.FileContent);
            if (!dataPackageSubmissionResult.IsSuccess)
            {
                if (dataPackageSubmissionResult.Error.IsClientError)
                {
                    return CentralConnectCode.SendMetricsClientError;
                }
                else if (dataPackageSubmissionResult.Error.IsReRegisterError)
                {
                    return CentralConnectCode.SendMetricsReRegisterError;
                }
                else if (dataPackageSubmissionResult.Error.IsTransientError)
                {
                    return CentralConnectCode.SendMetricsTransientError;
                }
            }
            MetricsMessage metricsMessage = new MetricsMessage();
            metricsMessage.Environment = metricsEnhancement.Environment;
            metricsMessage.ClientName = metricsEnhancement.ClientName;
            metricsMessage.Domain = metricsEnhancement.Domain;
            metricsMessage.PackageName = result.FileName;
            metricsMessage.ServicePartnerId = metricsEnhancement.ServicePartnerId;
            metricsMessage.SupportPartnerId = metricsEnhancement.SupportPartnerId;
            metricsMessage.CreateBy = "TBD";

            if (this.AddMetricsMessage(metricsMessage) != 1)
            {
                return CentralConnectCode.AddMetricsMessageFail;
            }
            return CentralConnectCode.Success;
        }
        public CentralConnectCode CreateAndSendMetrics(MetricsEnhancement metricsEnhancement)
        {
            //Client
            ClientAction  clientAction = new ClientAction(this.ConnectString);
            List <Client> clients      = clientAction.RetrieveClientByClientNameAndDomain(metricsEnhancement.ClientName, metricsEnhancement.Domain);

            if (clients.Count != 1)
            {
                return(CentralConnectCode.ClientNotFound);
            }
            Logger.Write("Client", clients[0]);
            Client client = clients[0];
            //Contact
            ContactAction  contactAction   = new ContactAction(this.ConnectString);
            List <Contact> primaryContacts = contactAction.RetrieveContactByFullName(client.PrimaryContact);

            if (primaryContacts.Count != 1)
            {
                return(CentralConnectCode.PrimaryContactNotFound);
            }
            Logger.Write("Retrieve PrimaryContacts", primaryContacts[0]);
            Contact        primaryContact    = primaryContacts[0];
            List <Contact> secondaryContacts = contactAction.RetrieveContactByFullName(client.SecondaryContact);

            if (secondaryContacts.Count != 1)
            {
                return(CentralConnectCode.SecondaryContactNotFound);
            }
            Logger.Write("Retrieve SecondaryContact", secondaryContacts[0]);
            Contact secondaryContact = secondaryContacts[0];
            //Company
            CompanyAction  companyAction = new CompanyAction(this.ConnectString);
            List <Company> companys      = companyAction.RetrieveCompanyByCompanyName(client.CompanyName);

            if (companys.Count != 1)
            {
                return(CentralConnectCode.CompanyNotFound);
            }
            Logger.Write("Retrieve Company", companys[0]);
            Company company = companys[0];
            //registerClientMessages
            List <RegisterClientMessage> registerClientMessages = this.RetrieveRegisterClientMessageByEnvironmentAndClientNameAndDomain(metricsEnhancement.Environment, metricsEnhancement.ClientName, metricsEnhancement.Domain);

            if (registerClientMessages.Count != 1)
            {
                return(CentralConnectCode.RegisterClientMessageNotExist);
            }
            Logger.Write("Retrieve registerClientMessages", registerClientMessages[0]);
            RegisterClientMessage registerClientMessage = registerClientMessages[0];
            //devices
            List <Device> devices = this.RetrieveRegisterDeviceByEnvironmentAndClientNameAndClientDomain(metricsEnhancement.Environment, metricsEnhancement.ClientName, metricsEnhancement.Domain);

            if (devices.Count == 0)
            {
                return(CentralConnectCode.ClientNotFoundAssociatedDevice);
            }
            Logger.Write("Retrieve devices", devices);

            MetricsRequest metricsRequest = new MetricsRequest();
            //ClientInformation
            ClientInformation clientInformation = new ClientInformation();

            clientInformation.ClientName            = metricsEnhancement.ClientName;
            clientInformation.Domain                = metricsEnhancement.Domain;
            clientInformation.ProductNumber         = client.ProductNumber;
            clientInformation.SerialNumber          = client.SerialNumber;
            clientInformation.CoreSystemModel       = client.CoreSystemModel;
            clientInformation.MAC                   = client.MAC;
            clientInformation.OSName                = client.OSName;
            clientInformation.OSVersion             = client.OSVersion;
            clientInformation.IPAddress             = client.IPAddress;
            clientInformation.HPPID                 = registerClientMessage.HPPID;
            clientInformation.Password              = registerClientMessage.Password;
            clientInformation.CSID                  = registerClientMessage.CSID;
            clientInformation.OSGDID                = registerClientMessage.OSGDID;
            clientInformation.HWGDID                = registerClientMessage.HWGDID;
            clientInformation.RegistrationToken     = registerClientMessage.RegistrationToken;
            clientInformation.CompanyName           = client.CompanyName;
            clientInformation.CountryCode           = company.CountryCode;
            clientInformation.StateProvince         = company.StateProvince;
            clientInformation.City                  = company.City;
            clientInformation.Street                = company.Street;
            clientInformation.PostalCode            = company.PostalCode;
            clientInformation.PrimaryContact        = client.PrimaryContact;
            clientInformation.PrimaryFirstName      = primaryContact.FirstName;
            clientInformation.PrimaryLastName       = primaryContact.LastName;
            clientInformation.PrimaryEmailAddress   = primaryContact.EmailAddress;
            clientInformation.PrimaryPhone          = primaryContact.Phone;
            clientInformation.SecondaryContact      = client.SecondaryContact;
            clientInformation.SecondaryFirstName    = secondaryContact.FirstName;
            clientInformation.SecondaryLastName     = secondaryContact.LastName;
            clientInformation.SecondaryEmailAddress = secondaryContact.EmailAddress;
            clientInformation.SecondaryPhone        = secondaryContact.Phone;
            clientInformation.SupportPartnerId      = metricsEnhancement.SupportPartnerId;
            clientInformation.ServicePartnerId      = metricsEnhancement.ServicePartnerId;
            metricsRequest.ClientInformation        = clientInformation;
            //deviceinformation
            DeviceAction             deviceAction       = new DeviceAction(this.ConnectString);
            List <DeviceInformation> deviceInformations = new List <DeviceInformation>();

            foreach (Device item in devices)
            {
                DeviceInformation deviceInformation = new DeviceInformation();
                deviceInformation.ClientName      = client.ClientName;
                deviceInformation.ClientDomain    = client.Domain;
                deviceInformation.DeviceName      = item.DeviceName;
                deviceInformation.Domain          = item.Domain;
                deviceInformation.ProductNumber   = item.ProductNumber;
                deviceInformation.SerialNumber    = item.SerialNumber;
                deviceInformation.CoreSystemModel = item.CoreSystemModel;
                deviceInformation.MAC             = item.MAC;
                deviceInformation.OSName          = item.OSName;
                deviceInformation.OSVersion       = item.OSVersion;
                deviceInformation.IPAddress       = item.IPAddress;
                List <RegisterDeviceMessage> registerDeviceMessages = deviceAction.RetrieveRegisterDeviceMessageByEnvironmentAndDeviceNameAndDomain(metricsEnhancement.Environment, item.DeviceName, item.Domain);
                if (registerDeviceMessages.Count != 1)
                {
                    return(CentralConnectCode.RegisterDeviceMessageNotExist);
                }
                RegisterDeviceMessage registerDeviceMessage = registerDeviceMessages[0];
                deviceInformation.OSGDID            = registerDeviceMessage.OSGDID;
                deviceInformation.OSGDIDUsn         = registerDeviceMessage.OSGDIDUsn;
                deviceInformation.HWGDID            = registerDeviceMessage.HWGDID;
                deviceInformation.HWGDIDUsn         = registerDeviceMessage.HWGDIDUsn;
                deviceInformation.CollectionProblem = registerDeviceMessage.CollectionProblem;
                deviceInformation.MonitoringProblem = registerDeviceMessage.MonitoringProblem;
                deviceInformations.Add(deviceInformation);
            }
            metricsRequest.DeviceInformations = deviceInformations;
            //enhancementArguments
            Dictionary <string, string> enhancementArguments = new Dictionary <string, string>();

            if (metricsEnhancement.Arguments != null)
            {
                foreach (Argument item in metricsEnhancement.Arguments)
                {
                    if (!enhancementArguments.ContainsKey(item.key))
                    {
                        enhancementArguments.Add(item.key, item.value);
                    }
                }
            }
            metricsRequest.EnhancementArguments = enhancementArguments;
            //InvokeMetrics Plugin
            EnhancementAction enhancementAction = new EnhancementAction(this.ConnectString);
            PluginResponse    result            = enhancementAction.InvokeMetrics(metricsRequest, metricsEnhancement.Type);

            if (!result.IsSuccess)
            {
                Logger.Write("CreateMetricsFail-" + result.Message);
                return(CentralConnectCode.CreateMetricsFail);
            }
            //SendMetrics
            DictionaryAction            dictionaryAction            = new DictionaryAction(this.ConnectString);
            string                      serviceUrl                  = string.Format("{0}/{1}", dictionaryAction.RetrieveServiceUrl(metricsEnhancement.Environment), "DataPackageReceiver/DataPackageReceiver.asmx");
            DataPackageSubmissionResult dataPackageSubmissionResult = this.SendMetricsRequest(serviceUrl,
                                                                                              registerClientMessage.CSID,
                                                                                              registerClientMessage.HWGDID,
                                                                                              registerClientMessage.OSGDID,
                                                                                              registerClientMessage.RegistrationToken,
                                                                                              result.FileName,
                                                                                              result.FileContent);

            if (!dataPackageSubmissionResult.IsSuccess)
            {
                if (dataPackageSubmissionResult.Error.IsClientError)
                {
                    return(CentralConnectCode.SendMetricsClientError);
                }
                else if (dataPackageSubmissionResult.Error.IsReRegisterError)
                {
                    return(CentralConnectCode.SendMetricsReRegisterError);
                }
                else if (dataPackageSubmissionResult.Error.IsTransientError)
                {
                    return(CentralConnectCode.SendMetricsTransientError);
                }
            }
            MetricsMessage metricsMessage = new MetricsMessage();

            metricsMessage.Environment      = metricsEnhancement.Environment;
            metricsMessage.ClientName       = metricsEnhancement.ClientName;
            metricsMessage.Domain           = metricsEnhancement.Domain;
            metricsMessage.PackageName      = result.FileName;
            metricsMessage.ServicePartnerId = metricsEnhancement.ServicePartnerId;
            metricsMessage.SupportPartnerId = metricsEnhancement.SupportPartnerId;
            metricsMessage.CreateBy         = "TBD";

            if (this.AddMetricsMessage(metricsMessage) != 1)
            {
                return(CentralConnectCode.AddMetricsMessageFail);
            }
            return(CentralConnectCode.Success);
        }
        CentralConnectServiceResponse ICentralConnectService.RetrieveRegisterDeviceMessageByEnvironmentAndDeviceNameAndDomain(CentralConnectServiceRequest centralConnectServiceRequest)
        {
            if (centralConnectServiceRequest.RegisterDeviceMessage == null)
            {
                return new CentralConnectServiceResponse() { Code = 400, Message = "RegisterDeviceMessage should not null" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.Environment)
                || string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.DeviceName)
                || string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.Domain))
            {
                return new CentralConnectServiceResponse() { Code = 400, Message = "Environment DeviceName Domain should not null" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.Id)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Token)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Type))
            {
                return new CentralConnectServiceResponse() { Code = 400, Message = "Id Type and Token should not null" };
            }

            string message = string.Empty;
            if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, centralConnectServiceRequest, out message))
            {
                return new CentralConnectServiceResponse() { Code = 403, Message = centralConnectServiceRequest.Id + " of type " + centralConnectServiceRequest.Type + " have no access of " + message };
            }

            DeviceAction deviceAction = new DeviceAction(this.ConnectString);
            List<RegisterDeviceMessage> registerDeviceMessages = deviceAction.RetrieveRegisterDeviceMessageByEnvironmentAndDeviceNameAndDomain(centralConnectServiceRequest.RegisterDeviceMessage.Environment, centralConnectServiceRequest.RegisterDeviceMessage.DeviceName, centralConnectServiceRequest.RegisterDeviceMessage.Domain);
            return new CentralConnectServiceResponse() { Code = 0, Message = "Success", RegisterDeviceMessages = registerDeviceMessages };
        }
        Core.ServiceResponse ICentralConnectService.CreateDevice(CentralConnectServiceRequest centralConnectServiceRequest)
        {
            if (centralConnectServiceRequest.Device == null)
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Device should not null" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.Device.DeviceName)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.Domain)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.ProductNumber)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.SerialNumber)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.CoreSystemModel)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.OSName)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.OSVersion)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.ClientName)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.ClientDomain)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Device.CreateBy))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "DeviceName Domain ProductNumber SerialNumber CoreSystemModel OSName OSVersion ClientName ClientDomain CreateBy should not null" };
            }

            if ((centralConnectServiceRequest.Device.DeviceName == centralConnectServiceRequest.Device.ClientName)
                && (centralConnectServiceRequest.Device.Domain == centralConnectServiceRequest.Device.ClientDomain))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "DeviceName Domain should not same as ClientName ClientDomain" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.Id)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Token)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Type))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" };
            }

            string message = string.Empty;
            if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, centralConnectServiceRequest, out message))
            {
                return new Core.ServiceResponse() { Code = 403, Message = centralConnectServiceRequest.Id + " of type " + centralConnectServiceRequest.Type + " have no access of " + message };
            }

            DeviceAction deviceAction = new DeviceAction(this.ConnectString);
            CentralConnectCode centralConnectCode = deviceAction.CreateDevice(centralConnectServiceRequest.Device);
            if (CentralConnectCode.Success != centralConnectCode)
            {
                return new Core.ServiceResponse() { Code = 500, Message = "CreateDevice Fail of " + Enum.GetName(typeof(CentralConnectCode), centralConnectCode) };
            }

            return new Core.ServiceResponse() { Code = 0, Message = "Success" };
        }
        Core.ServiceResponse ICentralConnectService.RegisterDevice(CentralConnectServiceRequest centralConnectServiceRequest)
        {
            if (centralConnectServiceRequest.RegisterDeviceMessage == null)
            {
                return new Core.ServiceResponse() { Code = 400, Message = "RegisterDeviceMessage should not null" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.Environment)
                || string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.DeviceName)
                || string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.Domain)
                || string.IsNullOrEmpty(centralConnectServiceRequest.RegisterDeviceMessage.CreateBy))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Environment DeviceName Domain CreateBy should not null" };
            }

            if (string.IsNullOrEmpty(centralConnectServiceRequest.Id)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Token)
                || string.IsNullOrEmpty(centralConnectServiceRequest.Type))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" };
            }
            string message = string.Empty;
            if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, centralConnectServiceRequest, out message))
            {
                return new Core.ServiceResponse() { Code = 403, Message = centralConnectServiceRequest.Id + " of type " + centralConnectServiceRequest.Type + " have no access of " + message };
            }
            DeviceAction deviceAction = new DeviceAction(this.ConnectString);
            CentralConnectCode centralConnectCode = deviceAction.RegisterDevice(centralConnectServiceRequest.RegisterDeviceMessage.Environment,
                centralConnectServiceRequest.RegisterDeviceMessage.DeviceName,
                centralConnectServiceRequest.RegisterDeviceMessage.Domain,
                centralConnectServiceRequest.RegisterDeviceMessage.CreateBy);
            if (CentralConnectCode.Success != centralConnectCode)
            {
                return new Core.ServiceResponse() { Code = 500, Message = "RegisterDevice Fail of " + Enum.GetName(typeof(CentralConnectCode), centralConnectCode) };
            }
            return new Core.ServiceResponse() { Code = 0, Message = "Success" };
        }