Ejemplo n.º 1
0
        /// <summary>
        /// Prints the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="vals">The vals.</param>
        private void Print(string message, params object[] vals)
        {
            FxLog <CloudServiceHostFactory>
            .DebugFormat(message, vals);

            Debug.Print(message, vals);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="connectionKey">The connection key.</param>
        /// <param name="affectedTable">The affected table.</param>
        /// <param name="application">The application.</param>
        /// <param name="operation">The operation.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="affectedFieldInfo">The affected field info.</param>
        public static void Audit(string connectionKey, string affectedTable, string application, string operation, string userName, string affectedFieldInfo)
        {
            Stopwatch timer = Stopwatch.StartNew();

            string connectionString = ConfigurationManager.ConnectionStrings[connectionKey].ConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "Broobu.Audit_Insert";
                    cmd.Parameters.AddRange(new[]
                    {
                        new SqlParameter("@AffectedDatabase", con.Database),
                        new SqlParameter("@AffectedTable", affectedTable),
                        new SqlParameter("@Application", application),
                        new SqlParameter("@Operation", operation),
                        new SqlParameter("@DateTime", DateTime.Now),
                        new SqlParameter("@User", userName),
                        new SqlParameter("@AffectedFieldInfo", affectedFieldInfo)
                    });

                    con.Open();
                    cmd.ExecuteNonQuery();
                }

            timer.Stop();
            FxLog <Auditor> .DebugFormat("Audit record inserted ({0})", timer.ToStringInSeconds());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a Type instance from information contained in the appSettings of the configuration file.
        /// </summary>
        /// <param name="appSettingsKey">The key in the app settings where the Type information is stored.</param>
        /// <returns>Type.</returns>
        /// <exception cref="System.ApplicationException"></exception>
        public static Type CreateTypeFromConfiguration(string appSettingsKey)
        {
            string typeName;

            if (GetTypeInfo(appSettingsKey, out typeName))
            {
                Type type;
                try
                {
                    type = Type.GetType(typeName, throwOnError: true /* throw error if not found */);
                }
                catch (Exception ex)
                {
                    string errorMessage = string.Format(
                        "Failed to create Type object from information in configuration file (AppSettings key {0})"
                        + ", typeName = {1}",
                        appSettingsKey, typeName);
                    throw new ApplicationException(errorMessage, ex);
                }
                FxLog <TypeFactory> .DebugFormat("Created Type object from information in configuration file (AppSettings key {0})"
                                                 + ", typeName = {1}",
                                                 appSettingsKey, typeName);

                return(type);
            }
            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Terminates the session async.
        /// </summary>
        /// <param name="postLogoffAction">The act.</param>
        public static void TerminateSessionAsync(Action postLogoffAction = null)
        {
            Messenger.Default.Send(new NavigateMvvmMessage()
            {
                Header    = WaitInfo.Header,
                ViewName  = WaitView.ID,
                Parameter = WaitInfo
            });
            Logger.Info("{0}, Reason: {1}", WaitInfo.Title, WaitInfo.Reason);
            FxLog <AuthenticationHost> .DebugFormat(WaitInfo.Title);

            _postLogoffAction = postLogoffAction;
            if (WulkaSession.Current != null)
            {
                AuthenticationPortal
                .Authentication
                .TerminateSessionAsync(TerminateSessionAsyncCompleted);
            }
            else
            {
                if (_postLogoffAction != null)
                {
                    _postLogoffAction.Invoke();
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the cloud contract.
        /// </summary>
        /// <param name="contractId">The contract identifier.</param>
        /// <returns>CloudContract.</returns>
        public CloudContract GetCloudContract(string contractId)
        {
            FxLog <CloudContracts> .DebugFormat("Get Cloud Contract: {0}", contractId);

            var res = Provider <CloudContract> .GetById(contractId);

            FxLog <CloudContracts> .DebugFormat("\t{0} | {1}", res.Id, res.Binding);

            return(res);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the type information.
        /// </summary>
        /// <param name="appSettingsKey">The application settings key.</param>
        /// <param name="instanceTypeName">Name of the instance type.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private static bool GetTypeInfo(string appSettingsKey, out string instanceTypeName)
        {
            instanceTypeName = ConfigurationManager.AppSettings[appSettingsKey];
            if (string.IsNullOrEmpty(instanceTypeName))
            {
                FxLog <TypeFactory> .DebugFormat(
                    "No Type information found in configuration file for AppSettings key {0})",
                    appSettingsKey);

                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// To the XML document.
        /// </summary>
        /// <param name="inputStream">The input stream.</param>
        /// <returns>XmlDocument.</returns>
        private static XmlDocument ToXmlDocument(Stream inputStream)
        {
            XmlDocument xmlDocument = new XmlDocument();

            try
            {
                xmlDocument.Load(inputStream);
            }
            catch (Exception ex)
            {
                FxLog <XmlFormatter> .DebugFormat("Failed to load XmlDocument from input stream --> {0}", ex.Message);
            }
            return(xmlDocument); // Empty if error occurred
        }
Ejemplo n.º 8
0
        /// <summary>
        /// To the XML document.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns>XmlDocument.</returns>
        private static XmlDocument ToXmlDocument(byte[] input)
        {
            MemoryStream memoryStream = new MemoryStream(input);
            XmlDocument  xmlDocument  = new XmlDocument();

            try
            {
                xmlDocument.Load(memoryStream);
            }
            catch (Exception ex)
            {
                FxLog <XmlFormatter> .DebugFormat("Failed to load XmlDocument from byte array --> {0}", ex.GetCombinedMessages());
            }
            return(xmlDocument); // Empty if error occurred
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets all endpoint addresses.
        /// </summary>
        /// <returns>DiscoItem[][].</returns>
        public DiscoItem[] GetAllEndpointAddresses()
        {
            try
            {
                return(Business.DiscoProvider
                       .Discos
                       .GetAllEndpointAddresses());
            }
            catch (Exception exception)
            {
                FxLog <DiscoSentry> .DebugFormat("Error getting all endpoint addresses. Error: {0}", exception.Message);

                throw;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the endpoints.
        /// </summary>
        /// <param name="contractType">The scope.</param>
        /// <returns>SerializableEndpoint[][].</returns>
        public SerializableEndpoint[] GetEndpoints(string contractType)
        {
            try
            {
                return(DiscoProvider
                       .Discos
                       .GetEndpoints(contractType));
            }
            catch (Exception exception)
            {
                FxLog <DiscoSentry> .DebugFormat("Error getting Endpoints from {0}. Error: {1}", contractType, exception.Message);

                throw;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Requests from pool.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns>T.</returns>
        internal static T RequestFromPool <T>()
            where T : class
        {
            if (EnableConnectionPool)
            {
                IClientBase instance;
                if (Current._openProxiesByType.TryGetValue(typeof(T), out instance))
                {
                    FxLog <ProxyConnectionPool> .DebugFormat("Retrieving proxy {0} from ConnectionPool.", instance);

                    return((T)instance);
                }
            }
            return(null);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Saves the cloud contract.
        /// </summary>
        /// <param name="contract">The contract.</param>
        /// <returns>CloudContract.</returns>
        public CloudContract SaveCloudContract(CloudContract contract)
        {
            FxLog <CloudContracts> .DebugFormat("Registering service contract for [{0}]", contract.Id);

            try
            {
                contract = Provider <CloudContract> .Save(contract);
            }
            catch (Exception ex)
            {
                FxLog <CloudContracts> .LogException(ex);

                contract.AddError(ex.Message);
            }
            return(contract);
        }
Ejemplo n.º 13
0
        public void Try_SaveCloudContract()
        {
            try
            {
                var n = new CloudContract()
                {
                    Id = "TestCloudContract", Publisher = "me"
                };
                var res = DiscoProvider
                          .CloudContracts
                          .SaveCloudContract(n);
                Console.WriteLine("Saved CloudContract [{0}]", res.Id);
                FxLog <DiscoTestFixture> .DebugFormat("Saved CloudContract [{0}]", res.Id);
            }
            catch (Exception exception)
            {
                FxLog <DiscoTestFixture> .ErrorFormat(exception.GetCombinedMessages());

                Assert.Fail(exception.Message);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Saves the cloud contracts.
        /// </summary>
        /// <param name="contracts">The contracts.</param>
        /// <returns>CloudContract[][].</returns>
        public CloudContract[] SaveCloudContracts(CloudContract[] contracts)
        {
            var lst = new List <CloudContract>();

            FxLog <CloudContracts> .DebugFormat("Registering Cloud Contracts:");

            foreach (var cloudContract in contracts)
            {
                try
                {
                    var res = SaveCloudContract(cloudContract);
                    lst.Add(res);
                }
                catch (Exception ex)
                {
                    FxLog <CloudContracts> .LogException(ex);

                    cloudContract.AddError(ex.Message);
                    lst.Add(cloudContract);
                }
            }
            return(lst.ToArray());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Internals the register.
        /// </summary>
        /// <param name="clientBase">The client base.</param>
        private void InternalRegister(IClientBase clientBase)
        {
            FxLog <ProxyConnectionPool> .DebugFormat("Registering client {0}", clientBase);

            _openProxies[clientBase] = clientBase;
        }
Ejemplo n.º 16
0
 public void Try_DebugLogging()
 {
     FxLog <DomainTestFixture> .DebugFormat("I am writing a Debug Log Message");
 }