public CentralConnectCode CreateClient(Client client)
        {
            //Contact
            ContactAction  contactAction   = new ContactAction(this.ConnectString);
            List <Contact> primaryContacts = contactAction.RetrieveContactByFullName(client.PrimaryContact);

            if (primaryContacts.Count != 1)
            {
                return(CentralConnectCode.PrimaryContactNotFound);
            }
            List <Contact> secondaryContacts = contactAction.RetrieveContactByFullName(client.SecondaryContact);

            if (secondaryContacts.Count != 1)
            {
                return(CentralConnectCode.SecondaryContactNotFound);
            }
            //Company
            CompanyAction  companyAction = new CompanyAction(this.ConnectString);
            List <Company> companys      = companyAction.RetrieveCompanyByCompanyName(client.CompanyName);

            if (companys.Count != 1)
            {
                return(CentralConnectCode.CompanyNotFound);
            }
            if (Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(this.ConnectString, "SP_CreateCentralConnectClient", client.ClientName, client.Domain, client.ProductNumber, client.SerialNumber, client.CoreSystemModel, client.OSName, client.OSVersion, client.CompanyName, client.PrimaryContact, client.SecondaryContact, client.CreateBy) != 1)
            {
                return(CentralConnectCode.CreateClientFail);
            }
            return(CentralConnectCode.Success);
        }
        // check if a company has a Main child company
        // a company may have only one main child company
        private static bool IsParentCompanyWithChild(this CompanyModel company, CompanyAction action)
        {
            CompanyModel companyToCompare;

            if (company.ParentCompanyId != null)
            {
                companyToCompare = MvcApplication.Companies.First(x => x.Id == company.ParentCompanyId);

                if (action == CompanyAction.Delete &&
                    (companyToCompare.HasSubsidiaries ||
                     companyToCompare.HasChildCompany))
                {
                    return(true);
                }

                else
                {
                    if (companyToCompare.HasChildCompany)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        Core.ServiceResponse ICompanyService.CreateCompany(CompanyServiceRequest companyServiceRequest)
        {
            if (companyServiceRequest.Company == null)
            {
                return(new Core.ServiceResponse()
                {
                    Code = 400, Message = "Company should not null"
                });
            }

            if (string.IsNullOrEmpty(companyServiceRequest.Company.CompanyName) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.CountryCode) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.StateProvince) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.City) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.Street) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.PostalCode) ||
                string.IsNullOrEmpty(companyServiceRequest.Company.CreateBy))
            {
                return(new Core.ServiceResponse()
                {
                    Code = 400, Message = "CompanyName CountryCode StateProvince City Street PostalCode CreateBy should not null"
                });
            }

            if (string.IsNullOrEmpty(companyServiceRequest.Id) ||
                string.IsNullOrEmpty(companyServiceRequest.Token) ||
                string.IsNullOrEmpty(companyServiceRequest.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, companyServiceRequest, out message))
            {
                return(new Core.ServiceResponse()
                {
                    Code = 403, Message = companyServiceRequest.Id + " of type " + companyServiceRequest.Type + " have no access of " + message
                });
            }

            CompanyAction companyAction = new CompanyAction(this.ConnectString);

            if (companyAction.CreateCompany(companyServiceRequest.Company) <= 0)
            {
                return(new Core.ServiceResponse()
                {
                    Code = 500, Message = "Create Company Fail"
                });
            }

            return(new Core.ServiceResponse()
            {
                Code = 0, Message = "Success"
            });
        }
        // check if a has a parent company
        private static bool IsWithParent(this CompanyModel company, CompanyAction action)
        {
            if (company.ParentCompanyId != null)
            {
                return(company.IsParentCompanyWithChild(action));
            }

            return(false);
        }
        Core.ServiceResponse ICompanyService.RemoveCompanyByCompanyName(CompanyServiceRequest companyServiceRequest)
        {
            if (companyServiceRequest.Company == null)
            {
                return(new Core.ServiceResponse()
                {
                    Code = 400, Message = "Company should not null"
                });
            }

            if (string.IsNullOrEmpty(companyServiceRequest.Company.CompanyName))
            {
                return(new Core.ServiceResponse()
                {
                    Code = 400, Message = "CompanyName should not null"
                });
            }

            if (string.IsNullOrEmpty(companyServiceRequest.Id) ||
                string.IsNullOrEmpty(companyServiceRequest.Token) ||
                string.IsNullOrEmpty(companyServiceRequest.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, companyServiceRequest, out message))
            {
                return(new Core.ServiceResponse()
                {
                    Code = 403, Message = companyServiceRequest.Id + " of type " + companyServiceRequest.Type + " have no access of " + message
                });
            }

            CompanyAction companyAction = new CompanyAction(this.ConnectString);

            if (companyAction.RemoveCompanyByCompanyName(companyServiceRequest.Company.CompanyName) <= 0)
            {
                return(new Core.ServiceResponse()
                {
                    Code = 500, Message = "Remove Company Fail"
                });
            }

            return(new Core.ServiceResponse()
            {
                Code = 0, Message = "Success"
            });
        }
Пример #6
0
 private void FaceToData(ref CompanyAction value)
 {
     value.Name       = this.NameID.Text;
     value.Content    = this.ContentID.Text;
     value.Remark     = this.RemarkID.Text;
     value.Free       = decimal.Parse(this.FreeID.Text);
     value.ActionDate = DateTime.Parse(this.ActionDateID.Text);
     if (this.DropWorkNameID.SelectedValue.IsInt())
     {
         value.WorkName = DependencyResolver.Resolver <ICooperationService>().FindById(int.Parse(this.DropWorkNameID.SelectedValue));
     }
     value.State    = AspNetHelper.GetItemByDropDownValue(this.StateID);
     value.Evaluate = AspNetHelper.GetItemByDropDownValue(this.EvaluateID);
     value.FiledIds = value.FiledIds + "," + Request.GetRequestValue("fileID").Trim(',');
     if (value.Company != null)
     {
         value.Company = this.CurrentCompany;
     }
 }
Пример #7
0
        private void DataToFace(CompanyAction value)
        {
            if (value == null)
            {
                FreeID.Text = "0";
                return;
            }
            this.NameID.Text       = value.Name;
            this.ContentID.Text    = value.Content;
            this.RemarkID.Text     = value.Remark;
            this.FreeID.Text       = value.Free.ToString();
            this.ActionDateID.Text = value.ActionDate.ToShortDateString();
            if (value.WorkName != null)
            {
                this.DropWorkNameID.SelectedValue = value.WorkName.Id.ToString();
            }

            AspNetHelper.SetDropDownSelectedvalue(this.StateID, value.State);
            AspNetHelper.SetDropDownSelectedvalue(this.EvaluateID, value.Evaluate);
            files.InnerHtml = AspNetHelper.DownLoadFile(value.FiledIds);
        }
Пример #8
0
        // method converts Company into CompanyModel for both Update and Add methods
        public static Company ToCompany(this CompanyModel company, CompanyAction action)
        {
            Company convertedCompany;

            if (action == CompanyAction.Add)
            {
                convertedCompany = new Company();
            }
            else
            {
                convertedCompany = MvcApplication.CompanyBusinessLogic.GetById(company.Id);
            }

            convertedCompany.Name           = company.Name;
            convertedCompany.AnnualEarnings = company.Earnings;
            convertedCompany.CompanyType    = MvcApplication.CompanyBusinessLogic.GetCompanyType(company.Type);

            if (company.ParentCompanyId != null)
            {
                convertedCompany.ParentCompany =
                    MvcApplication.CompanyBusinessLogic.GetParentCompany(company.ParentCompanyId);
            }
            return(convertedCompany);
        }
        public CentralConnectCode RegisterDevice(string environment, string deviceName, string domain, string createBy)
        {
            List <RegisterDeviceMessage> registerDeviceMessages = this.RetrieveRegisterDeviceMessageByEnvironmentAndDeviceNameAndDomain(environment, deviceName, domain);

            if (registerDeviceMessages.Count > 0)
            {
                return(CentralConnectCode.RegisterDeviceMessageExist);
            }
            DictionaryAction dictionaryAction = new DictionaryAction(this.ConnectString);
            string           serviceUrl       = string.Format("{0}/{1}", dictionaryAction.RetrieveServiceUrl(environment), "OOSRegistration/OOSRegistrationService.svc");

            Logger.Write(string.Format("ServiceUrl={0},DeviceName={1},Domain={2}", serviceUrl, deviceName, domain));
            //Device
            List <Device> devices = this.RetrieveDeviceByDeviceNameAndDomain(deviceName, domain);

            if (devices.Count != 1)
            {
                return(CentralConnectCode.DeviceNotFound);
            }
            Logger.Write("Retrieve Device", devices[0]);
            Device device = devices[0];
            //RegisterClientMessage
            ClientAction clientAction = new ClientAction(this.ConnectString);
            List <RegisterClientMessage> registerClientMessages = clientAction.RetrieveRegisterClientMessageByEnvironmentAndClientNameAndDomain(environment, device.ClientName, device.ClientDomain);

            if (registerClientMessages.Count != 1)
            {
                return(CentralConnectCode.ClientNotRegister);
            }
            Logger.Write("RegisterClientMessage", registerClientMessages[0]);
            RegisterClientMessage registerClientMessage = registerClientMessages[0];
            //Client
            List <Client> clients = clientAction.RetrieveClientByClientNameAndDomain(device.ClientName, device.ClientDomain);

            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];

            //Request
            HP.TS.Devops.CentralConnect.OOSRegistration.RequestBody requestBody = new HP.TS.Devops.CentralConnect.OOSRegistration.RequestBody()
            {
                AutoDetectedSystemSerialNumber = device.SerialNumber,
                ProductId              = device.ProductNumber,
                SystemModel            = device.CoreSystemModel,
                CoreSystemModel        = device.CoreSystemModel,
                Hostname               = device.DeviceName,
                FQDN                   = string.Format("{0}.{1}", device.DeviceName, device.Domain),
                IPAddress              = device.IPAddress,
                Client_HPPID           = registerClientMessage.HPPID,
                MacAddress             = device.MAC,
                OSNameAndVersionString = string.Format("{0},{1}", device.OSName, device.OSVersion),
                //--prs--
                PRSAddress1   = company.Street,
                PRSCity       = company.City,
                PRSRegion     = company.StateProvince,
                PRSPostalCode = company.PostalCode,
                PRSCountry    = company.CountryCode,
                //--ISEEEnt---
                ISEEEntSerialNumber  = client.SerialNumber,
                ISEEEntProductNumber = client.ProductNumber,
                ISEEEntProductId     = client.ProductNumber,
                //--iseecus--
                ISEECusName = client.CompanyName,
                //--iseeperson--
                ISEEFirstPersonFirstName       = primaryContact.FirstName,
                ISEEFirstPersonLastName        = primaryContact.LastName,
                ISEEFirstPersonEmailAddress    = primaryContact.EmailAddress,
                ISEEFirstPersonTelephoneNumber = primaryContact.Phone,

                ISEESecondPersonFirstName       = secondaryContact.FirstName,
                ISEESecondPersonLastName        = secondaryContact.LastName,
                ISEESecondPersonEmailAddress    = secondaryContact.EmailAddress,
                ISEESecondPersonTelephoneNumber = secondaryContact.Phone,
            };
            Logger.Write("requestBody", requestBody);
            HP.TS.Devops.CentralConnect.OOSRegistration.OOSRegistrationServiceResult oosRegistrationServiceResult = this.RegisterDeviceRequest(serviceUrl, requestBody, registerClientMessage.CSID, registerClientMessage.OSGDID, registerClientMessage.RegistrationToken);
            if (!oosRegistrationServiceResult.IsSuccess)
            {
                Logger.Write("OOSRegistrationServiceResult Fail", oosRegistrationServiceResult);
                if (oosRegistrationServiceResult.Error.IsClientError)
                {
                    return(CentralConnectCode.RegisterDeviceClientError);
                }
                else if (oosRegistrationServiceResult.Error.IsReRegisterError)
                {
                    return(CentralConnectCode.RegisterDeviceReRegisterError);
                }
                else if (oosRegistrationServiceResult.Error.IsTransientError)
                {
                    return(CentralConnectCode.RegisterDeviceTransientError);
                }
            }
            RegisterDeviceMessage registerDeviceMessage = new RegisterDeviceMessage();

            registerDeviceMessage.Environment = environment;
            registerDeviceMessage.DeviceName  = deviceName;
            registerDeviceMessage.Domain      = domain;
            registerDeviceMessage.OSGDID      = oosRegistrationServiceResult.Gdid;
            registerDeviceMessage.OSGDIDUsn   = oosRegistrationServiceResult.OSGdidUsn.ToString();
            registerDeviceMessage.HWGDID      = oosRegistrationServiceResult.HWGdid;
            registerDeviceMessage.HWGDIDUsn   = oosRegistrationServiceResult.HWGdidUsn.ToString();
            registerDeviceMessage.CreateBy    = createBy;

            if (this.AddRegisterDeviceMessage(registerDeviceMessage) != 1)
            {
                return(CentralConnectCode.AddRegisterDeviceMessageFail);
            }
            return(CentralConnectCode.Success);
        }
        public CentralConnectCode RegisterClient(string environment, string clientName, string domain, string createBy)
        {
            List <RegisterClientMessage> registerClientMessages = this.RetrieveRegisterClientMessageByEnvironmentAndClientNameAndDomain(environment, clientName, domain);

            if (registerClientMessages.Count > 0)
            {
                return(CentralConnectCode.RegisterClientMessageExist);
            }
            DictionaryAction dictionaryAction = new DictionaryAction(this.ConnectString);
            string           serviceUrl       = string.Format("{0}/{1}", dictionaryAction.RetrieveServiceUrl(environment), "ClientRegistration/ClientRegistrationService.asmx");

            Logger.Write(string.Format("ServiceUrl={0},ClientName={1},Domain={2}", serviceUrl, clientName, domain));
            //Client
            List <Client> clients = this.RetrieveClientByClientNameAndDomain(clientName, domain);

            if (clients.Count != 1)
            {
                return(CentralConnectCode.ClientNotFound);
            }
            Logger.Write("Retrieve 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];

            //Request
            HP.TS.Devops.CentralConnect.ClientRegistration.RequestBody requestBody = new HP.TS.Devops.CentralConnect.ClientRegistration.RequestBody()
            {
                CoreSystemModel        = client.CoreSystemModel,
                ProductId              = client.ProductNumber,
                FQDN                   = string.Format("{0}.{1}", client.ClientName, client.Domain),
                Hostname               = client.ClientName,
                OSNameAndVersionString = string.Format("{0},{1}", client.OSName, client.OSVersion),
                SystemModel            = client.CoreSystemModel,
                MacAddress             = client.MAC,
                IPAddress              = client.IPAddress,
                PRSCaption             = client.CompanyName,
                PRSDirtyFlag           = 1,
                PRSUniqueName          = client.CompanyName,
                PRSAddress1            = company.Street,
                PRSCity                = company.City,
                PRSRegion              = company.StateProvince,
                PRSPostalCode          = company.PostalCode,
                PRSCountry             = company.CountryCode,
                ISEECusCaption         = client.CompanyName,
                ISEECusPRSUniqueName   = client.CompanyName,
                ISEECusName            = client.CompanyName,
                ISEEEntSerialNumber    = client.SerialNumber,
                ISEEEntProductNumber   = client.ProductNumber,
                ISEEEntProductId       = client.ProductNumber,

                ISEEFirstPersonFirstName       = primaryContact.FirstName,
                ISEEFirstPersonLastName        = primaryContact.LastName,
                ISEEFirstPersonEmailAddress    = primaryContact.EmailAddress,
                ISEEFirstPersonTelephoneNumber = primaryContact.Phone,

                ISEESecondPersonFirstName       = secondaryContact.FirstName,
                ISEESecondPersonLastName        = secondaryContact.LastName,
                ISEESecondPersonEmailAddress    = secondaryContact.EmailAddress,
                ISEESecondPersonTelephoneNumber = secondaryContact.Phone,
            };
            Logger.Write("requestBody", requestBody);
            string xmlEscapedCSID = string.Empty;

            HP.TS.Devops.CentralConnect.ClientRegistration.ClientRegistrationResult result = this.RegisterClientRequest(serviceUrl, requestBody, out xmlEscapedCSID);
            Logger.Write("ClientRegistration Result", result);
            //load to database
            if (!result.IsSuccess)
            {
                return(CentralConnectCode.ClientRegistrationFail);
            }
            RegisterClientMessage registerClientMessage = new RegisterClientMessage();

            registerClientMessage.Environment       = environment;
            registerClientMessage.ClientName        = clientName;
            registerClientMessage.Domain            = domain;
            registerClientMessage.CSID              = xmlEscapedCSID;
            registerClientMessage.OSGDID            = result.Gdid;
            registerClientMessage.RegistrationToken = result.RegistrationToken;
            registerClientMessage.HWGDID            = result.Gdid;
            registerClientMessage.CreateBy          = createBy;

            if (this.AddRegisterClientMessage(registerClientMessage) != 1)
            {
                return(CentralConnectCode.AddRegisterClientMessageFail);
            }
            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);
        }