Example #1
0
        /// ****************************************************************
        ///   public InnerSave
        ///	----------------------------------------------------------------
        ///	  <summary>
        ///		Stores the bindingTemplate details into the database.
        ///	  </summary>
        /// ****************************************************************
        ///
        internal void InnerSave(string serviceKey)
        {
            if (0 == ServiceKey.Length)
            {
                ServiceKey = serviceKey;
            }
            else
            {
                Debug.Verify(0 == String.Compare(ServiceKey, serviceKey, true), "UDDI_ERROR_INVALIDKEYPASSED_BINDINGPROJECTION", ErrorType.E_invalidKeyPassed);
            }

            if (Utility.StringEmpty(BindingKey))
            {
                //
                // This is an insert so, generate a bindingkey
                //
                BindingKey = Guid.NewGuid().ToString();
            }

            SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_bindingTemplate_save");

            sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID);
            sp.Parameters.Add("@bindingKey", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@serviceKey", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@generic", SqlDbType.VarChar, UDDI.Constants.Lengths.generic);
            sp.Parameters.Add("@URLTypeID", SqlDbType.TinyInt);
            sp.Parameters.Add("@accessPoint", SqlDbType.NVarChar, UDDI.Constants.Lengths.AccessPoint);
            sp.Parameters.Add("@hostingRedirector", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@lastChange", SqlDbType.BigInt);

            sp.Parameters.SetString("@PUID", Context.User.ID);
            sp.Parameters.SetGuidFromString("@bindingKey", BindingKey);
            sp.Parameters.SetGuidFromString("@serviceKey", ServiceKey);
            sp.Parameters.SetString("@generic", Constants.Version);
            sp.Parameters.SetGuid("@contextID", Context.ContextID);

            if (null != AccessPoint)
            {
                sp.Parameters.SetShort("@URLTypeID", (short)AccessPoint.URLType);
                sp.Parameters.SetString("@accessPoint", AccessPoint.Value);
            }

            if (null != HostingRedirector)
            {
                sp.Parameters.SetGuidFromString("@hostingRedirector", HostingRedirector.BindingKey);
            }

            sp.Parameters.SetLong("@lastChange", DateTime.UtcNow.Ticks);
            sp.ExecuteNonQuery();

            //
            // Save all contained objects.
            //
            Descriptions.Save(BindingKey, EntityType.BindingTemplate);
            TModelInstanceInfos.Save(BindingKey);
        }
Example #2
0
 public void SaveAll()
 {
     Customers.Save();
     Descriptions.Save();
     Employees.Save();
     Positions.Save();
     Orders.Save();
     Products.Save();
     ProductOrders.Save();
 }
Example #3
0
        public void Save(string businessKey)
        {
            //
            // Create a command object to invoke the stored procedure
            //
            SqlCommand cmd = new SqlCommand("net_businessEntity_contact_save", ConnectionManager.GetConnection());

            cmd.Transaction = ConnectionManager.GetTransaction();
            cmd.CommandType = CommandType.StoredProcedure;

            //
            // Parameters
            //
            cmd.Parameters.Add(new SqlParameter("@businessKey", SqlDbType.UniqueIdentifier)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@useType", SqlDbType.NVarChar, UDDI.Constants.Lengths.UseType)).Direction       = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@personName", SqlDbType.NVarChar, UDDI.Constants.Lengths.PersonName)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@contactID", SqlDbType.BigInt)).Direction = ParameterDirection.Output;

            //
            // Set parameter values and execute query
            //
            SqlParameterAccessor parmacc = new SqlParameterAccessor(cmd.Parameters);

            parmacc.SetGuidFromString("@businessKey", businessKey);
            parmacc.SetString("@personName", PersonName);
            parmacc.SetString("@useType", UseType);

            cmd.ExecuteScalar();

            //
            // Move out parameters into local variables
            //
            long ContactID = parmacc.GetLong("@contactID");

            //
            // Save sub-objects
            //
            Descriptions.Save(ContactID, EntityType.Contact);
            Phones.Save(ContactID);
            Emails.Save(ContactID);
            Addresses.Save(ContactID);
        }
Example #4
0
        /// **********************************************************************
        ///   public Save
        /// ----------------------------------------------------------------------
        ///   <summary>
        ///   </summary>
        /// **********************************************************************
        ///
        public override void Save()
        {
            Debug.Enter();

            //
            // Validate the business entity.
            //
            Validate();

            //
            // Check to see if a business key was specified.  If not, this is a new
            // record and a business key will have to be generated.
            //
            if (Utility.StringEmpty(BusinessKey))
            {
                BusinessKey = Guid.NewGuid().ToString();
            }

            //
            // Save the entity to the database.
            //
            SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_businessEntity_save");

            sp.Parameters.Add("@businessKey", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID);
            sp.Parameters.Add("@generic", SqlDbType.VarChar, UDDI.Constants.Lengths.generic);
            sp.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@lastChange", SqlDbType.BigInt);
            sp.Parameters.Add("@authorizedName", SqlDbType.NVarChar, UDDI.Constants.Lengths.AuthorizedName, ParameterDirection.InputOutput);
            sp.Parameters.Add("@operatorName", SqlDbType.NVarChar, UDDI.Constants.Lengths.Operator, ParameterDirection.InputOutput);

            sp.Parameters.SetGuidFromString("@businessKey", BusinessKey);
            sp.Parameters.SetString("@PUID", Context.User.ID);
            sp.Parameters.SetString("@generic", Constants.Version);
            sp.Parameters.SetGuid("@contextID", Context.ContextID);
            sp.Parameters.SetLong("@lastChange", DateTime.UtcNow.Ticks);
            sp.Parameters.SetString("@authorizedName", AuthorizedName);
            sp.Parameters.SetString("@operatorName", this.Operator);

            //
            // We won't set the operatorName since this will be derived from the PUID
            //

            sp.ExecuteNonQuery();

            AuthorizedName = sp.Parameters.GetString("@authorizedName");
            Operator       = sp.Parameters.GetString("@operatorName");

            //
            // Save all the contained objects.
            //
            DiscoveryUrls.Save(BusinessKey);

            if (Operator == Config.GetString("Operator"))
            {
                //
                // Only add the default discovery Url to this business
                // If it was published at this site.
                //
                DiscoveryUrls.AddDefaultDiscoveryUrl(BusinessKey);
            }

            Names.Save(BusinessKey, EntityType.BusinessEntity);
            Descriptions.Save(BusinessKey, EntityType.BusinessEntity);
            Contacts.Save(BusinessKey);
            BusinessServices.Save(BusinessKey);
            IdentifierBag.Save(BusinessKey, EntityType.BusinessEntity, KeyedReferenceType.IdentifierBag);
            CategoryBag.Save(BusinessKey, EntityType.BusinessEntity, KeyedReferenceType.CategoryBag);

            //
            // Save the change log entry for replication
            //
            if (Context.LogChangeRecords)
            {
                //
                // If we used a V1 API message, make sure to add in language codes for the names.  We will
                // then take these names out after we save the change record.
                //
                if (1 == Context.ApiVersionMajor)
                {
                    foreach (Name name in Names)
                    {
                        name.IsoLangCode = Context.User.IsoLangCode;
                    }
                }

                ChangeRecord changeRecord = new ChangeRecord();
                changeRecord.Payload = new ChangeRecordNewData(this);
                changeRecord.Log();

                //
                // Take out language names if we are using V1.
                //
                if (1 == Context.ApiVersionMajor)
                {
                    foreach (Name name in Names)
                    {
                        name.IsoLangCode = null;
                    }
                }
            }

            Debug.Leave();
        }