コード例 #1
0
        private void WriteOperatorMessage(string message, object payload)
        {
            UTF8EncodedStringWriter writer = new UTF8EncodedStringWriter();

            writer.Write(message);
            writer.Write(" ");
            writer.WriteLine(DateTime.Now);
            writer.WriteLine("\r\nRaw Request:");
            writer.WriteLine("");

            if (null != payload)
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(payload.GetType());
                    serializer.Serialize(writer, payload);
                }
                catch
                {
                    writer.WriteLine("Unable to serialize payload.");
                }
                finally
                {
                    writer.Close();
                }
            }
            Debug.OperatorMessage(SeverityType.Info,
                                  CategoryType.Replication,
                                  OperatorMessageType.None,
                                  writer.ToString());
        }
コード例 #2
0
ファイル: cache.cs プロジェクト: hadkins1/Windows-Server-2003
        /// ****************************************************************
        ///   public Save
        /// ----------------------------------------------------------------
        ///   <summary>
        ///	    Stores the cache object in the session cache.
        ///   </summary>
        /// ----------------------------------------------------------------
        ///   <param name="userID">
        ///     The user id.
        ///   </param>
        ///
        ///   <param name="cacheObject">
        ///     The cache object.
        ///   </param>
        /// ****************************************************************
        ///
        public static void Save(string userID, CacheObject cache)
        {
            Debug.Enter();

            //
            // Serialize the data into a stream.
            //
            XmlSerializer           serializer = new XmlSerializer(typeof(CacheObject));
            UTF8EncodedStringWriter writer     = new UTF8EncodedStringWriter();

            serializer.Serialize(writer, cache);

            //
            // Write the cache object to the database.
            //
            SqlCommand cmd = new SqlCommand("UI_setSessionCache", ConnectionManager.GetConnection());

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

            cmd.Parameters.Add(new SqlParameter("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@cacheValue", SqlDbType.NText)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@context", SqlDbType.NVarChar, UDDI.Constants.Lengths.Context)).Direction = ParameterDirection.Input;

            cmd.Parameters["@PUID"].Value       = userID;
            cmd.Parameters["@cacheValue"].Value = writer.ToString();
            cmd.Parameters["@context"].Value    = "WebServer";

            cmd.ExecuteNonQuery();

            Debug.Leave();
        }
コード例 #3
0
        void DisplayChangeRecord(ChangeRecord changeRecord)
        {
            UTF8EncodedStringWriter writer = new UTF8EncodedStringWriter();

            changeRecordSerializer.Serialize(writer, changeRecord);
            writer.Close();

            changeRecordTextBox.Text = writer.ToString();
        }
コード例 #4
0
        void DisplayCorrection(ChangeRecord changeRecord)
        {
            ChangeRecordCorrection changeRecordCorrection = new ChangeRecordCorrection();

            changeRecordCorrection.ChangeRecord = changeRecord;

            UTF8EncodedStringWriter writer = new UTF8EncodedStringWriter();

            correctionSerializer.Serialize(writer, changeRecordCorrection);
            writer.Close();

            correctionTextBox.Text = writer.ToString();
        }
コード例 #5
0
        public override string ToString()
        {
            XmlSerializer           serializer   = new XmlSerializer(GetType());
            UTF8EncodedStringWriter stringWriter = new UTF8EncodedStringWriter();

            try
            {
                serializer.Serialize(stringWriter, this);
                return(stringWriter.ToString());
            }
            finally
            {
                stringWriter.Close();
            }
        }
コード例 #6
0
        private static string Serialize(object obj)
        {
            UTF8EncodedStringWriter stringWriter = new UTF8EncodedStringWriter();

            try
            {
                XmlSerializer           serializer = new XmlSerializer(obj.GetType());
                XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                namespaces.Add("", "urn:uddi-org:api_v2");

                serializer.Serialize(stringWriter, obj, namespaces);
            }
            finally
            {
                stringWriter.Close();
            }

            return(stringWriter.ToString());
        }
コード例 #7
0
        public long Log()
        {
            string changeData;

            //
            // Serialize the change data.
            //
            Type type = Payload.GetType();

            //XmlSerializer serializer = new XmlSerializer( type );
            XmlSerializer           serializer   = XmlSerializerManager.GetSerializer(type);
            XmlSerializerNamespaces namespaces   = new XmlSerializerNamespaces();
            UTF8EncodedStringWriter stringWriter = new UTF8EncodedStringWriter();

            try
            {
                namespaces.Add("", "urn:uddi-org:repl");

                serializer.Serialize(stringWriter, Payload, namespaces);
                changeData = stringWriter.ToString();
            }
            finally
            {
                stringWriter.Close();
            }

            //
            // Store the record in the change log.
            //
            SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor("net_changeRecord_save");

            sp.Parameters.Add("@USN", SqlDbType.BigInt);
            sp.Parameters.Add("@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID);
            sp.Parameters.Add("@delegatePUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID);
            sp.Parameters.Add("@operatorKey", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@entityKey", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@entityTypeID", SqlDbType.TinyInt);
            sp.Parameters.Add("@changeTypeID", SqlDbType.TinyInt);
            sp.Parameters.Add("@contextID", SqlDbType.UniqueIdentifier);
            sp.Parameters.Add("@contextTypeID", SqlDbType.TinyInt);
            sp.Parameters.Add("@lastChange", SqlDbType.BigInt);
            sp.Parameters.Add("@changeData", SqlDbType.NText);
            sp.Parameters.Add("@flag", SqlDbType.Int);
            sp.Parameters.Add("@seqNo", SqlDbType.BigInt, ParameterDirection.Output);

            if (Utility.StringEmpty(ChangeID.NodeID) ||
                0 == String.Compare(Config.GetString("OperatorKey"), ChangeID.NodeID, true))
            {
                sp.Parameters.SetNull("@USN");
                sp.Parameters.SetString("@PUID", Context.User.ID);
                sp.Parameters.SetString("@delegatePUID", Context.User.ImpersonatorID);
                sp.Parameters.SetNull("@operatorKey");
            }
            else
            {
                sp.Parameters.SetLong("@USN", changeID.OriginatingUSN);
                sp.Parameters.SetNull("@PUID");
                sp.Parameters.SetNull("@delegatePUID");
                sp.Parameters.SetGuidFromString("@operatorKey", changeID.NodeID);
            }

            sp.Parameters.SetGuid("@contextID", Context.ContextID);
            sp.Parameters.SetInt("@flag", AcknowledgementRequested ? 0x1 : 0x0);
            sp.Parameters.SetLong("@lastChange", DateTime.UtcNow.Ticks);
            sp.Parameters.SetShort("@contextTypeID", (short)Context.ContextType);
            sp.Parameters.SetShort("@changeTypeID", (short)Payload.ChangeRecordPayloadType);

            if (Payload is ChangeRecordNewData)
            {
                ChangeRecordNewData payload = (ChangeRecordNewData)Payload;

                sp.Parameters.SetShort("@entityTypeID", (short)payload.EntityType);

                if (EntityType.TModel == payload.EntityType)
                {
                    sp.Parameters.SetGuidFromKey("@entityKey", payload.Entity.EntityKey);
                }
                else
                {
                    sp.Parameters.SetGuidFromString("@entityKey", payload.Entity.EntityKey);
                }
            }
            else if (Payload is ChangeRecordDelete)
            {
                ChangeRecordDelete payload = (ChangeRecordDelete)Payload;

                sp.Parameters.SetShort("@entityTypeID", (short)payload.EntityType);

                if (EntityType.TModel == payload.EntityType)
                {
                    sp.Parameters.SetGuidFromKey("@entityKey", payload.EntityKey);
                }
                else
                {
                    sp.Parameters.SetGuidFromString("@entityKey", payload.EntityKey);
                }
            }
            else if (Payload is ChangeRecordHide)
            {
                sp.Parameters.SetShort("@entityTypeID", (short)EntityType.TModel);
                sp.Parameters.SetGuidFromKey("@entityKey", ((ChangeRecordHide)Payload).TModelKey);
            }
            else
            {
                sp.Parameters.SetNull("@entityTypeID");
                sp.Parameters.SetNull("@entityKey");
            }

            sp.Parameters.SetString("@changeData", changeData);

            sp.ExecuteNonQuery();

            return(sp.Parameters.GetLong("@seqNo"));
        }