Example #1
0
        public void TestPersistence()
        {
            var connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            var p = new SqlPersistence
            {
                ConnectionString = connectionString
            };

            var clientId = Guid.NewGuid().ToString();
            var md5      = new byte[16] {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6
            };
            var msg     = new byte[] { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
            var headers = new NameValueCollection();

            headers.Add("hello", "world");

            var sw = new Stopwatch();

            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.InsertMessage(DateTime.UtcNow, clientId, md5, msg, headers);
                scope.Complete();
            }

            Trace.WriteLine("insert:" + sw.ElapsedTicks);
            sw.Reset();

            NameValueCollection outHeaders;

            byte[] outMessage;


            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.AckMessage(clientId, md5, out outMessage, out outHeaders);
                scope.Complete();
            }
            Trace.WriteLine("ack:" + sw.ElapsedTicks);
            sw.Reset();

            sw.Start();
            int deleted;

            using (var scope = new TransactionScope())
            {
                deleted = p.DeleteDeliveredMessages(DateTime.UtcNow - TimeSpan.FromSeconds(2));
                scope.Complete();
            }
            sw.Stop();
            Trace.WriteLine("delete:" + sw.ElapsedTicks);

            if (deleted > 0)
            {
                Trace.WriteLine("DELETED ROWS:" + deleted);
            }
        }
Example #2
0
        internal static SqlPersistence CreateSqlPersistence(ConnectionManager connectionManager)
        {
            var icons       = TestConnectionManager.CreateTestFavoriteIcons();
            var persistence = new SqlPersistence(icons, connectionManager);

            persistence.Initialize();
            return(persistence);
        }
Example #3
0
        public void TestPersistence()
        {
            var connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            var p = new SqlPersistence
            {
                ConnectionString = connectionString
            };

            var clientId = Guid.NewGuid().ToString();
            var msg      = new byte[] { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
            var headers  = new Dictionary <string, string> {
                { "hello", "world" }
            };

            var sw = new Stopwatch();

            sw.Start();
            using (var scope = new TransactionScope())
                using (var msgStream = new MemoryStream(msg))
                {
                    p.InsertMessage(clientId, DateTime.UtcNow, msgStream, headers);
                    scope.Complete();
                }

            Trace.WriteLine("insert:" + sw.ElapsedTicks);
            sw.Reset();

            IDictionary <string, string> outHeaders;

            byte[] outMessage;


            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.AckMessage(clientId, out outMessage, out outHeaders);
                scope.Complete();
            }
            Trace.WriteLine("ack:" + sw.ElapsedTicks);
            sw.Reset();

            sw.Start();
            int deleted;

            using (var scope = new TransactionScope())
            {
                deleted = p.DeleteDeliveredMessages(DateTime.UtcNow - TimeSpan.FromSeconds(2));
                scope.Complete();
            }
            sw.Stop();
            Trace.WriteLine("delete:" + sw.ElapsedTicks);

            if (deleted > 0)
            {
                Trace.WriteLine("DELETED ROWS:" + deleted);
            }
        }
        public void TestPersistence()
        {
            var connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            var p = new SqlPersistence
                        {
                            ConnectionString = connectionString
                        };

            var clientId = Guid.NewGuid().ToString();
            var md5 = new byte[16] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6};
            var msg = new byte[] {8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8};
            var headers = new NameValueCollection();
            headers.Add("hello", "world");

            var sw = new Stopwatch();
            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.InsertMessage(DateTime.UtcNow, clientId, md5, msg, headers);
                scope.Complete();
            }

            Trace.WriteLine("insert:" + sw.ElapsedTicks);
            sw.Reset();

            NameValueCollection outHeaders;
            byte[] outMessage;

            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.AckMessage(clientId, md5, out outMessage, out outHeaders);
                scope.Complete();
            }
            Trace.WriteLine("ack:" + sw.ElapsedTicks);
            sw.Reset();

            sw.Start();
            int deleted;
            using (var scope = new TransactionScope())
            {
                deleted = p.DeleteDeliveredMessages(DateTime.UtcNow - TimeSpan.FromSeconds(2));
                scope.Complete();
            }
            sw.Stop();
            Trace.WriteLine("delete:" + sw.ElapsedTicks);

            if (deleted > 0)
                Trace.WriteLine("DELETED ROWS:" + deleted);
        }
Example #5
0
        public void TestPersistence()
        {
            var connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            var p = new SqlPersistence
                        {
                            ConnectionString = connectionString
                        };

            var clientId = Guid.NewGuid().ToString();
            var msg = new byte[] {8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8};
            var headers = new Dictionary<string,string> {{"hello", "world"}};

            var sw = new Stopwatch();
            sw.Start();
            using (var scope = new TransactionScope())
            using(var msgStream  = new MemoryStream(msg))
            {
                p.InsertMessage(clientId,DateTime.UtcNow, msgStream, headers);
                scope.Complete();
            }

            Trace.WriteLine("insert:" + sw.ElapsedTicks);
            sw.Reset();

            IDictionary<string,string> outHeaders;
            byte[] outMessage;

            sw.Start();
            using (var scope = new TransactionScope())
            {
                p.AckMessage(clientId, out outMessage, out outHeaders);
                scope.Complete();
            }
            Trace.WriteLine("ack:" + sw.ElapsedTicks);
            sw.Reset();

            sw.Start();
            int deleted;
            using (var scope = new TransactionScope())
            {
                deleted = p.DeleteDeliveredMessages(DateTime.UtcNow - TimeSpan.FromSeconds(2));
                scope.Complete();
            }
            sw.Stop();
            Trace.WriteLine("delete:" + sw.ElapsedTicks);

            if (deleted > 0)
                Trace.WriteLine("DELETED ROWS:" + deleted);
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlEventStore{TKey}"/> class.
 /// </summary>
 /// <param name="persistence">The <see cref="SqlPersistence">persistence</see> associated with the event store.</param>
 public SqlEventStore(SqlPersistence persistence) : base(persistence)
 {
     Configuration      = persistence.Configuration.Events;
     Snapshots          = Configuration.CreateSnapshotStore <TKey>();
     snapshotSerializer = new SnapshotSerializer(typeof(TKey), Configuration);
 }
Example #7
0
        private static DataSet GetDataSet(string repository, string alias, Hashtable ht)
        {
            DataSet ds = new DataSet();

            config = new ConfigHelper();
            _dataRepository = config.GetRepository(repository);

            if (ht != null)
                ds = _dataRepository.LoadDataSet(alias, ht);
            else
                ds = _dataRepository.LoadDataSet(alias);

            return ds;
        }
Example #8
0
        private string GetPriorDate()
        {
            strUserIdentity = "fountainhead\bgoff";
            GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
            CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

            config = new ConfigHelper();
            _dataRepository = config.GetRepository("Persistence");

            Hashtable ht = new Hashtable();
            ht["date"] = DateTime.Now.Date;
            ht["CountryArr"] = "US";

            DataSet ds = GetDataSet("Persistence", "Persistence.StaarsConversion_GetPriorDate", ht);

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                return ((DateTime)ds.Tables[0].Rows[0][0]).ToShortDateString();
            else
                return String.Empty;
        }
Example #9
0
        public override int Execute(Object o, Hashtable inputData)
        {
            int activityIdStarting = UpdateProcessStatus(Enums.ProcessStatus.Starting, "", (State)o );

            if (IfResetOnEachRun)
                ResetOutput();

            PassAlongOutputs(inputData);

            strUserIdentity = "fountainhead\bgoff";
            GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
            CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

            config = new ConfigHelper();
            _dataRepository = config.GetRepository(repositoryName);

            DataSet ds = GetDataSet(repositoryName, sqlAlias, null);
            AddToOutputs(this.Name, ds);

            //Hashtable ht = new Hashtable();
            //foreach (Object oIn in inputData)
            //{
            //    DataTable dt = oIn as DataTable;
            //    foreach (DataRow dr in dt.Rows)
            //    {
            //        GetDataSet(repositoryName, sqlAlias, null);
            //    }
            //}

            int activityIdEnding = UpdateProcessStatus(Enums.ProcessStatus.Success, "", (State)o );

            log.InfoFormat(job.KeyCode, "PersistenceAdapter executed.");
            return 0;
        }
        public override int Execute(Object o, Hashtable inputData)
        {
            int activityIdStarting = UpdateProcessStatus(Enums.ProcessStatus.Starting, "", (State)o );

            if (IfResetOnEachRun)
                ResetOutput();

            PassAlongOutputs(inputData);

            strUserIdentity = "fountainhead\bgoff";
            GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
            CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

            config = new ConfigHelper();
            _dataRepository = config.GetRepository("GenevaPersistence");

            Hashtable ht = new Hashtable();
            foreach (Object oIn in inputData)
            {
                DataTable dt = oIn as DataTable;
                foreach (DataRow dr in dt.Rows)
                {
                    ht.Clear();

                    switch (columnMapMode)
                    {
                        case 0:
                            for (int i = 0; i < columnCount; i++)
                                ht[dt.Columns[i].ColumnName] = dr[i];
                            break;
                    }

                    //string pquery = String.Format("GenevaPersistence.{0}", query);
                    GetDataSet("GenevaPersistence", query, ht);
                }
            }

            int activityIdEnding = UpdateProcessStatus(Enums.ProcessStatus.Success, "", (State)o );

            log.InfoFormat(job.KeyCode, "GenevaPersistenceAdapter executed.");
            return 0;
        }
        public override int Execute(Object o, Hashtable inputData)
        {
            int activityIdStarting = UpdateProcessStatus(Enums.ProcessStatus.Starting, "", (State)o );

            if (IfResetOnEachRun)
                ResetOutput();

            PassAlongOutputs(inputData);

            strUserIdentity = "fountainhead\bgoff";
            GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
            CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

            config = new ConfigHelper();
            _dataRepository = config.GetRepository("PersistenceAdapter");

            Hashtable ht = new Hashtable();
            foreach (Object oIn in inputData)
            {
                DataTable dt = oIn as DataTable;
                foreach (DataRow dr in dt.Rows)
                {
                    ht.Clear();

                    ht["entryDate"] = dr[0];
                    ht["datasource"] = dr[1];
                    ht["tradeDate"] = dr[2];
                    ht["symbol"] = dr[3];
                    ht["side"] = dr[4];
                    ht["quantity"] = dr[5];
                    ht["price"] = dr[6];

                    GetDataSet("Persistence", "Persistence.13fReport_SaTradeDelete", ht);
                    GetDataSet("Persistence", "Persistence.13fReport_SaTradeInsert", ht);
                }
            }

            int activityIdEnding = UpdateProcessStatus(Enums.ProcessStatus.DoneSuccess, "", (State)o );

            log.InfoFormat("PersistenceAdapter executed.");
            return 0;
        }
Example #12
0
        private int UpdateActivityRun(int activityId, string name, string dataType, string source, int numrecs,
            loaderResultsStruct loaderReturn, Hashtable htIdentifierRef, Hashtable htSubTypeRef, Hashtable htTypeRef, Hashtable htXmlData)
        {
            int ret = 0;

            try
            {
                string strUserIdentity = "fountainhead\bgoff";
                GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
                CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

                _dataRepository = config.GetRepository("GenevaPersistence");

                Hashtable ht = new Hashtable();
                Hashtable htRef = BuildSubTypeNameLookup();
                Hashtable htRecType = BuildRecordTypeLookup();

                int i = 0;
                if (loaderReturn.results != null)
                {
                    foreach (loaderResultsVectorElement result in loaderReturn.results)
                    {
                        string subTypeName = String.Empty;
                        string recType = String.Empty; string identifier = String.Empty;

                        if (htRef.ContainsKey(result.message))
                            subTypeName = htRef[result.message].ToString();
                        if (htRecType.ContainsKey(result.message))
                            recType = htRecType[result.message].ToString();

                        if (subTypeName.Equals(String.Empty))
                        {
                            if (result.keyValue.Equals(String.Empty))
                            {
                                identifier = htIdentifierRef[i].ToString();
                            }
                            else if (htTypeRef.ContainsKey(result.keyValue))
                            {
                                subTypeName = htSubTypeRef[result.keyValue].ToString();
                                identifier = result.keyValue;
                                recType = htTypeRef[result.keyValue].ToString();
                            }
                            else
                            {
                                subTypeName = "EquityNewType";
                                identifier = result.keyValue;
                            }
                        }

                        int rc = 0;
                        Int32.TryParse(result.code, out rc);

                        XmlDocument xdocXmlData = (XmlDocument)htXmlData[i++];

                        if (xdocXmlData != null)
                        {
                            XmlNode exceptionsNode = xdocXmlData.CreateElement("Exceptions", xdocXmlData.DocumentElement.NamespaceURI);

                            XmlNode exceptionNode = xdocXmlData.CreateElement("GenevaErrorCode", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionNode.InnerXml = result.code;
                            XmlNode exceptionMsgNode = xdocXmlData.CreateElement("Message", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionMsgNode.InnerXml = result.message;

                            exceptionsNode.AppendChild(exceptionNode);
                            exceptionsNode.AppendChild(exceptionMsgNode);
                            xdocXmlData.FirstChild.AppendChild(exceptionsNode);

                            ht.Clear();
                            ht.Add("RunID", activityId);
                            ht.Add("xmlData", xdocXmlData.InnerXml);
                            ht.Add("SubTypeName", subTypeName);
                            ht.Add("Identifier", identifier);
                            ht.Add("UserID", 0);
                            ht.Add("UserGroupID", 0);
                            ht.Add("ExceptionStatusCode", "m");
                            ht.Add("UserName", String.Empty);
                            ht.Add("dataType", dataType);
                            ht.Add("RecordType", recType);
                            ht.Add("Code", rc);
                            ht.Add("Message", result.message);
                            ht.Add("SuccessKeyValue", result.keyValue);

                            _dataRepository.ExecuteScalar("GenevaPersistence.AddActivityRunDetail", ht);
                        }
                    }
                }
                else
                    log.Warn(job.KeyCode, "No results received from SOAP update.");

                ht.Clear();
                ht.Add("RunID", activityId);
                ht.Add("StatusCode", 'e');
                ht.Add("EndDateTime", DateTime.Now);
                ht.Add("NumberOfRecords", numrecs);
                ht.Add("Note", "");
                ht.Add("Source", source);
                ht.Add("MessageId", "");

                ret = _dataRepository.ExecuteScalar("GenevaPersistence.UpdateActivityRun", ht);
            }
            catch (Exception ex)
            {
                log.Error(job.KeyCode, ex);
            }

            return ret;
        }
Example #13
0
        private int AddActivityRun(string name, string source, int numrecs)
        {
            string strUserIdentity = "fountainhead\bgoff";
            GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
            CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

            _dataRepository = config.GetRepository("GenevaPersistence");

            Hashtable ht = new Hashtable();
            ht.Add("ActivityName", name);
            ht.Add("MessageID", activityName);
            ht.Add("Source", source);
            ht.Add("NumberOfRecords", numrecs);
            ht.Add("StatusCode", 'p');

            int ret = _dataRepository.ExecuteScalar("GenevaPersistence.AddActivityRun", ht);

            return ret;
        }
Example #14
0
        private SqlPersistence FillRepositoryInfo(NameValueCollection config, string name)
        {
            SqlPersistence repository = new SqlPersistence(config);

            return repository;
        }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlEventStore"/> class.
 /// </summary>
 /// <param name="persistence">The <see cref="SqlPersistence">persistence</see> associated with the event store.</param>
 public SqlEventStore(SqlPersistence persistence) : base(persistence)
 {
 }