Beispiel #1
0
        public static long ParseNumberId(string sNumberId)
        {
            lock (locker)
            {
                try
                {
                    //StationSettings settings = StationSettings.GetSettings;

                    //ExcpHelper.ThrowIf(settings == null, "Settings IS NULL");
                    ExcpHelper.ThrowIf(string.IsNullOrEmpty(m_sStationNumber), "Station Number is invalid");
                    ExcpHelper.ThrowIf(string.IsNullOrEmpty(sNumberId) || m_sStationNumber.Length >= sNumberId.Length, "Parsed Number is invalid");

                    int iStationNumberPos = sNumberId.IndexOf(m_sStationNumber, StringComparison.OrdinalIgnoreCase);

                    ExcpHelper.ThrowIf(iStationNumberPos != 0, "Cannot find current Station Number ('{0}') in incoming Number ('{1}')", m_sStationNumber, sNumberId);

                    string sLongToParse = sNumberId.Substring(m_sStationNumber.Length);

                    return(Convert.ToInt64(sLongToParse));
                }
                catch (Exception excp)
                {
                    Log.Error(ExcpHelper.FormatException(excp, "CRITICAL ERROR: SetLastTransactionId() - Cannot set last Transaction ID"), excp);
                }

                return(ERROR_NUMBER);
            }
        }
Beispiel #2
0
        public void Initialize()
        {
            try
            {
                ExcpHelper.ThrowIf(!File.Exists(this.ConfigFileName), "Database Configuration File does not exist: '{0}'", this.ConfigFileName);

                this.ConfigDocument = new XmlDocument();
                this.ConfigDocument.Load(this.ConfigFileName);

                this.CreateDatabaseStatement   = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/createDatabase");
                this.DeleteDatabaseStatement   = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/deleteDatabase");
                this.DatabaseExistsStatement   = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/databaseExists");
                this.TableExistsStatement      = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/tableExists");
                this.RequiredTables            = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/requiredTables");
                this.DeleteFromTablesStatement = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/deleteFromTables");
                this.DropTablesStatement       = XmlHelper.GetElementInnerText(this.ConfigDocument, "configuration/dropTables");

                this.TableStatements = new TableStatementList(this.ConfigDocument);
            }
            catch (Exception excp)
            {
                m_logger.Excp(excp, "DatabaseSchema.Initialize (DatabaseName='{0}', ConfigFileName='{1}') ERROR", this.DatabaseName, this.ConfigFileName);

                this.ConfigDocument       = null;
                this.TableExistsStatement = null;
                throw;
            }
        }
Beispiel #3
0
        private static void Analyze(FileInfo sFileName)
        {
            try
            {
                Assembly asm = Assembly.LoadFile(sFileName.FullName);

                if (asm != null)
                {
                    List <Type> lTypes = GetTypeList <ILineProvider>(asm);

                    m_logger.InfoFormat("Analyzing assembly {0} ({1})", asm.FullName, sFileName);

                    foreach (Type t in lTypes)
                    {
                        try
                        {
                            ILineProvider provider = Activator.CreateInstance(t) as ILineProvider;
                            ExcpHelper.ThrowIf(string.IsNullOrEmpty(provider.UniqueName), "Cannot create provider instance of type {0} from dll '{1}'. Unique Name is empty", t, sFileName);
                            m_diProviders.Add(provider.UniqueName, provider);
                        }
                        catch (Exception excp)
                        {
                            m_logger.Excp(excp, "Cannot create provider instance of type {0} from dll '{1}'", t, sFileName);
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                m_logger.Excp(excp, "Cannot get provider(s) from dll '{0}'", sFileName);
            }
        }
Beispiel #4
0
        public virtual void Update(IDbConnection conn, IDbTransaction transaction)
        {
            ExcpHelper.ThrowIf(this.Table == null, "TableSpec is not specified for type {0}", this.GetType());

            using (DataTable dtUpdate = DataCopyTables.GetEmptyDataTableByName(conn, transaction, this.Table.TableName))
            {
                using (IDbCommand cmdUpdate = DataCopy.GenerateUpdateCommand(conn, transaction, dtUpdate, this.Table))
                {
                    using (IDisposable dsp = SqlObjectFactory.CreateDbAdapter(null) as IDisposable)
                    {
                        IDbDataAdapter daUpdate = dsp as IDbDataAdapter;
                        Debug.Assert(daUpdate != null);

                        daUpdate.UpdateCommand = cmdUpdate;

                        DataRow dr = this.CreateDataRow(dtUpdate);

                        dtUpdate.Rows.Add(dr);
                        dtUpdate.AcceptChanges();
                        dr.SetModified();

                        using (DataSet ds = new DataSet())
                        {
                            ds.Tables.Add(dtUpdate);
                            daUpdate.Update(ds);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public static void EnsureInstance()
        {
            if (m_instance == null)
            {
                try
                {
                    m_instance = new BetDomainMap();

                    ExcpHelper.ThrowIf(!File.Exists(DalStationSettings.Instance.BetDomainMap), "BetDomain Map file does not exist {0}");

                    m_instance.m_di = new SyncDictionary <int, BetDomainMapItem>();

                    m_instance.m_doc = new XmlDocument();
                    m_instance.m_doc.Load(DalStationSettings.Instance.BetDomainMap);

                    GenerateTypes(typeof(BetTypeLn), m_instance.m_doc.SelectNodes("map/betType"), GenerateBetType);
                    GenerateTypes(typeof(ScoreTypeLn), m_instance.m_doc.SelectNodes("map/scoreType"), GenerateScoreType);
                    GenerateTypes(typeof(TimeTypeLn), m_instance.m_doc.SelectNodes("map/timeType"), GenerateTimeType);
                    GenerateTypes(typeof(BetDomainTypeLn), m_instance.m_doc.SelectNodes("map/betDomainType"), GenerateBetDomainType);
                }
                catch (Exception excp)
                {
                    m_logger.Excp(excp, "Cannot create instance");
                }
            }
        }
        public void Initialize(object objParam)
        {
            Log.Debug("init lineprovider");

            eFileSyncResult fsr = LineSr.SyncRoutines(eUpdateType.Initialize, "Adding bet types from configuration", DalStationSettings.Instance.UseDatabaseForLine, null, delegate(object obj)
            {
                BetDomainMap.EnsureInstance();
                return(false);
            });


            ExcpHelper.ThrowIf(fsr == eFileSyncResult.Failed, "Cannot initialize Bet Types");

            string sStationNumber = objParam as string;

            Debug.Assert(!string.IsNullOrEmpty(sStationNumber));

            LiveBetClient.Initialize(sStationNumber);
            VirtualLiveBetClient.Initialize(sStationNumber);
            PreMatchClient.Initialize(sStationNumber);
            StatisticsClient.Initialize(sStationNumber);
            MetainfoClient.Initialize(sStationNumber);
            //TournamentFlagsClient.Initialize(objParam.ToString());

#if ADD_OUTRIGHT_XML
            ImportOutrightExample();
            ImportOutrightExample();
#endif
        }
Beispiel #7
0
        public static eExistResult OneOfRequiredTablesExist(IDbConnection conn, IDbTransaction transaction)
        {
            try
            {
                string[] arrRequiredTables = DatabaseManager.Schema.RequiredTables.Split(new char[] { ',', ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string sRequiredTableName in arrRequiredTables)
                {
                    eExistResult err = DoesTableExist(conn, sRequiredTableName);
                    ExcpHelper.ThrowIf(err == eExistResult.Error, "Cannot recognize if table '{0}' exists.", sRequiredTableName);

                    if (err == eExistResult.Exists)
                    {
                        return(eExistResult.Exists);
                    }
                }

                return(eExistResult.DoesNotExist);
            }
            catch (Exception excp)
            {
                m_logger.Error(ExcpHelper.FormatException(excp, "OneOfRequiredTablesExist() ERROR"), excp);
            }

            return(eExistResult.Error);
        }
        public static void ProcessTransaction(IDbConnection conn, DelegateProcessTransaction dpt)
        {
            DateTime dtStart = DateTime.Now;

            try
            {
                // Check Stack to find nested transaction
                StackTrace st = new StackTrace();

                StackFrame[] sfArray = st.GetFrames();

                MethodBase mbThis = sfArray[0].GetMethod();

                for (int i = 1; i < sfArray.Length; i++)
                {
                    MethodBase mbStack = sfArray[i].GetMethod();

                    // If nested transaction detected then throw exception
                    ExcpHelper.ThrowIf(mbThis == mbStack, "Incorrect Operation: ProcessTransaction been called inside other ProcessTransaction. We do not support nested transactions:\r\n{0}\r\n", st);
                }

                // Delcare Transaction
                IDbTransaction transaction = null;

                try
                {
                    transaction = conn.BeginTransaction();

                    // Here we execute nHibernate statements
                    dpt(conn, transaction);

                    transaction.Commit();

                    DateTime dtEnd = DateTime.Now;
                    m_Logger.DebugFormat("ProcessTransaction({0}) Succeeded at {1} (Transaction Time: {2})", dpt.Method, dtEnd, dtEnd - dtStart);
                }
                catch (System.Exception excp1)
                {
                    m_Logger.ErrorFormat("ProcessTransaction({0}) ERROR:\r\n{1}\r\n{2}", excp1, dpt.Method, excp1.Message, excp1.StackTrace);

                    if (transaction != null)
                    {
                        try
                        {
                            transaction.Rollback();
                            m_Logger.WarnFormat("ProcessTransaction({0}) is ROLLED BACK", dpt.Method);
                        }
                        catch (Exception excp2)
                        {
                            m_Logger.ErrorFormat("ProcessTransaction({0}) Rollback Exception:\r\n{1}\r\n{2}", excp2, dpt.Method, excp2.Message, excp2.StackTrace);
                        }
                    }
                }
            }
            catch (Exception excp3)
            {
                m_Logger.ErrorFormat("ProcessTransaction({0}) General ERROR:\r\n{1}\r\n{2}", excp3, dpt.Method, excp3.Message, excp3.StackTrace);
                throw;
            }
        }
        public static SportRadarId Create(eVersionedObjectType vot, long lObjectId, UInt16 uiExtendedId, eLineType lt, UInt16 uiClientId)
        {
            try
            {
                ExcpHelper.ThrowIf <ArgumentException>(Math.Abs(lObjectId) > MAX_OBJECT_ID, "SportRadarId.Create(ObjectType={0}, ObjectId={1}, ExtendedId={2}, LineType={3}, Client={4}, ) ERROR. ObjectId is too big. MaxValue={5}",
                                                       vot, lObjectId, uiExtendedId, lt, uiClientId, MAX_OBJECT_ID);
                ExcpHelper.ThrowIf <ArgumentException>(uiExtendedId > MAX_EXTENDED_ID, "SportRadarId.Create(ObjectType={0}, ObjectId={1}, ExtendedId={2}, LineType={3}, Client={4}, ) ERROR. ExtendedId is too big. MaxValue={5}",
                                                       vot, lObjectId, uiExtendedId, lt, uiClientId, MAX_EXTENDED_ID);
                ExcpHelper.ThrowIf <ArgumentException>(uiClientId > MAX_CLIENT_ID, "SportRadarId.Create(ObjectType={0}, ObjectId={1}, ExtendedId={2}, LineType={3}, Client={4}, ) ERROR. ClientId is too big. MaxValue={5}",
                                                       vot, lObjectId, uiExtendedId, lt, uiClientId, MAX_CLIENT_ID);

                SportRadarId srid = new SportRadarId();

                srid.ObjectId   = lObjectId;
                srid.ExtendedId = uiExtendedId;
                srid.LineType   = lt;
                srid.ClientId   = uiClientId;
                srid.ObjectType = vot;

                return(srid);
            }
            catch (Exception excp)
            {
                throw;
            }

            return(null);
        }
Beispiel #10
0
        public override void SetRelations()
        {
            HashSet <string> hsPropertyNames = this.ChangedProps.GetPropertyNames();

            if (this.outright_type == eOutrightType.None)
            {
                if (this.HomeCompetitor == null || hsPropertyNames.Contains("HomeCompetitorId"))
                {
                    this.HomeCompetitor = LineSr.Instance.AllObjects.Competitors.GetObject(this.HomeCompetitorId.Value);
                    ExcpHelper.ThrowIf(this.HomeCompetitor == null, "MatchLn.SetRelations() ERROR. Cannot get Home Competitor for {0}", this);
                }

                if (this.AwayCompetitor == null || hsPropertyNames.Contains("AwayCompetitorId"))
                {
                    this.AwayCompetitor = LineSr.Instance.AllObjects.Competitors.GetObject(this.AwayCompetitorId.Value);
                    ExcpHelper.ThrowIf(this.AwayCompetitor == null, "MatchLn.SetRelations() ERROR. Cannot get Away Competitor for {0}", this);
                }
            }
            else if (m_diOutrightCompetitors == null)
            {
                m_diOutrightCompetitors = LineSr.Instance.AllObjects.CompetitorsToOutright.GetPositionToOutrightDictionaryByMatchId(this.MatchId);
                ExcpHelper.ThrowIf(m_diOutrightCompetitors == null, "MatchLn.SetRelations() ERROR. Cannot get Outright Competitors for {0}", this);
            }

            if (hsPropertyNames.Contains("Active"))
            {
                this.SetActiveChanged();
            }
        }
Beispiel #11
0
        public ILineObjectCollection <T> GetLineObjectCollection <T>() where T : ILineObject <T>
        {
            Type type = typeof(T);

            ExcpHelper.ThrowIf(!base.ContainsKey(type), "DictionaryOfLineObjectCollection does not contain collection for type '{0}'", type);

            return(this[type] as ILineObjectCollection <T>);
        }
Beispiel #12
0
        public RelatedObject(eObjectType eot, long lObjectId, long lMultiStringId)
        {
            ExcpHelper.ThrowIf <InvalidOperationException>(eot == eObjectType.TaggedString, "Related object cannot be with type TaggedString");

            this.ObjectType    = eot;
            this.ObjectId      = lObjectId;
            this.MultistringId = lMultiStringId;
        }
Beispiel #13
0
        public static string GetElementInnerText(XmlNode nodeSource, string sXPath)
        {
            XmlNode node = nodeSource.SelectSingleNode(sXPath);

            ExcpHelper.ThrowIf(node == null, "SelectSingleNode('{0}') ERROR. Node does not exist.", sXPath);

            return(node.InnerText);
        }
Beispiel #14
0
        public ILineObjectDictionaryByKey <T> GetLineObjectDictionaryByKey <T>() where T : ILineObjectWithKey <T>
        {
            ILineObjectDictionaryByKey <T> di = GetLineObjectCollection <T>() as ILineObjectDictionaryByKey <T>;

            ExcpHelper.ThrowIf(di == null, "DictionaryOfLineObjectCollection does not contain Dictionary(string Key) for type '{0}'", typeof(T));

            return(di);
        }
Beispiel #15
0
        public override T this[string sKey]
        {
            get
            {
                ExcpHelper.ThrowIf(true, "Method LineObjectDictionaryByIdBase<long, {0}>.this[] is obsolete. Use method GetObject() instead of.", typeof(T));

                return(default(T));
            }
        }
Beispiel #16
0
        protected void AddStrictlyImp(T objSource)
        {
            lock (m_oLocker)
            {
                ExcpHelper.ThrowIf(base.ContainsKey(objSource.Id), "LineObjectCollection<{0}>.AddStrictly({1}) ERROR. Such object already exists in database.", m_type.Name, objSource);

                base.Add(objSource.Id, objSource);
            }
        }
Beispiel #17
0
        private string SerializablePropertyToString(SerializableProperty sp)
        {
            Debug.Assert(sp.PropertyValue != null);
            string sName = sp.PropertyName.ToLowerInvariant();

            try
            {
                ExcpHelper.ThrowIf <InvalidOperationException>(!this.PropTypes.ContainsKey(sName), "Cannot find property type.");
                Type tProperty = this.PropTypes[sName];

                if (tProperty == typeof(Int32) || tProperty == typeof(Int32?))
                {
                    return(XmlConvert.ToString((Int32)sp.PropertyValue));
                }

                if (tProperty == typeof(Int64) || tProperty == typeof(Int64?))
                {
                    return(XmlConvert.ToString((Int64)sp.PropertyValue));
                }

                if (tProperty == typeof(DateTime) || tProperty == typeof(DateTime?))
                {
                    return(XmlConvert.ToString((DateTime)sp.PropertyValue));
                }

                if (tProperty == typeof(DateTimeSr))
                {
                    DateTimeSr dtsr = sp.PropertyValue as DateTimeSr;
                    Debug.Assert(dtsr != null);

                    return(dtsr.ToXmlString());
                }

                if (tProperty == typeof(bool) || tProperty == typeof(bool?))
                {
                    return(XmlConvert.ToString((bool)sp.PropertyValue));
                }

                if (tProperty == typeof(decimal) || tProperty == typeof(decimal?))
                {
                    return(XmlConvert.ToString((decimal)sp.PropertyValue));
                }

                if (tProperty.IsEnum)
                {
                    return(sp.PropertyValue.ToString());
                }

                return(sp.PropertyValue.ToString());
            }
            catch (Exception excp)
            {
                m_logger.Excp(excp, "SerializablePropertyToString({0}) ERROR.", sp);
                throw;
            }
        }
Beispiel #18
0
        public TableSpecification(string sTableName, bool bIsAutoGeneratedIdentity, params string[] argIdentityNames)
        {
            ExcpHelper.ThrowIf(string.IsNullOrEmpty(sTableName), "Table Name is empty");
            ExcpHelper.ThrowIf(argIdentityNames == null, "Identity Names are not specified");

            this.TableName = sTableName;
            this.IsAutoGeneratedIdentity = bIsAutoGeneratedIdentity;
            this.IdentityNames           = new List <string>(argIdentityNames);
            this.IdentityNames           = this.IdentityNames.ConvertAll(s => s.ToLowerInvariant());
        }
Beispiel #19
0
        /*
         * public string KeyName
         * {
         *  get { return GetKeyName(this.Discriminator, this.BetDomainNumber, this.IsLiveBet); }
         * }
         *
         * public static string GetKeyName(string sDiscriminator, string sBetDomainNumber, bool bIsLiveBet)
         * {
         *  return string.Format("{0}{1}{2}{3}{4}", sDiscriminator, KEY_SEPARATOR, sBetDomainNumber, KEY_SEPARATOR, bIsLiveBet ? "1" : "0");
         * }
         */

        public static BetDomainMapItem FromXmlElement(XmlElement el)
        {
            try
            {
                BetDomainMapItem bdmi = new BetDomainMapItem();

                string sIsLiveBet = el.GetAttribute("isLiveBet");

                string sBetDomainNumber = el.GetAttribute("betDomainNumber");
                string sSort            = el.GetAttribute("sort");
                string sPart            = el.GetAttribute("part");
                string sSubPart         = el.GetAttribute("subPart");
                string sArgsPart        = el.GetAttribute("argsCount");

                bdmi.Discriminator = el.GetAttribute("discriminator");
                bdmi.IsLiveBet     = sIsLiveBet == "1";
                bdmi.BetTag        = el.GetAttribute("betTag");
                bdmi.BetType       = el.GetAttribute("betType");
                bdmi.ScoreType     = el.GetAttribute("scoreType");
                bdmi.TimeType      = el.GetAttribute("timeType");
                bdmi.Generic       = el.GetAttribute("generic");

                //ExcpHelper.ThrowIf(string.IsNullOrEmpty(bdmi.Discriminator), "discriminator node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(sBetDomainNumber), "betDomainNumber node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(sIsLiveBet), "isLiveBet node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(bdmi.BetTag), "betTag node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(bdmi.BetType), "betType node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(bdmi.ScoreType), "scoreType node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(bdmi.TimeType), "timeType node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(sSort), "sort node is not set.");
                ExcpHelper.ThrowIf(string.IsNullOrEmpty(sPart), "part node is not set.");

                bdmi.BetDomainNumber = Convert.ToInt32(sBetDomainNumber);
                bdmi.Sort            = Convert.ToInt32(sSort);
                bdmi.Part            = Convert.ToInt32(sPart);

                try
                {
                    bdmi.SubPart = string.IsNullOrEmpty(sSubPart) ? 0 : Convert.ToInt32(sSubPart);
                }
                catch (Exception)
                {
                    bdmi.SubPart = 0;
                }

                bdmi.ArgsCount = string.IsNullOrEmpty(sArgsPart) ? 0 : Convert.ToInt32(sArgsPart);

                return(bdmi);
            }
            catch (Exception excp)
            {
                m_logger.Excp(excp, "BetDomainMapItem() ERROR.");
                throw;
            }
        }
Beispiel #20
0
        public void UpdateMaxKilobyteSize(string sMaxKilobyteSize)
        {
            int iMaxKilobyteSize = DEFAULT_MAX_KILOBYTE_SIZE;

            if (!string.IsNullOrEmpty(sMaxKilobyteSize))
            {
                ExcpHelper.ThrowIf(!int.TryParse(sMaxKilobyteSize, out iMaxKilobyteSize), "SimpleLogger init ERROR: Cannot get MaxKilobyteSize param.");
            }

            m_lMaxSize = iMaxKilobyteSize * KILOBYTE;
        }
Beispiel #21
0
        public void AddStrictly(T objSource)
        {
            string sKey = LineObjectCollection <T> .GetKeyName(objSource);

            ExcpHelper.ThrowIf(base.ContainsKey(sKey), "LineObjectCollection<{0}>.AddStrictly({1}) ERROR. Such object already exists in database.", m_type.Name, objSource);

            lock (m_oLocker)
            {
                base.Add(sKey, objSource);
            }
        }
Beispiel #22
0
        public override void AddStrictly(GroupLn objSource)
        {
            lock (m_oLocker)
            {
                AddStrictlyImp(objSource);

                ExcpHelper.ThrowIf(m_diKeyToGroup.ContainsKey(objSource.KeyName), "GroupDictionary.AddStrictly({1}) ERROR. Such object already exists in database.", m_type.Name, objSource);

                m_diKeyToGroup.Add(objSource.KeyName, objSource);
            }
        }
        private static void MergeMatchResult(MatchLn mtch)
        {
            try
            {
                MatchResultLn rslt = new MatchResultLn();

                rslt.MatchId                = mtch.MatchId;
                rslt.BtrMatchId             = mtch.BtrMatchId;
                rslt.StartDate.Value        = mtch.StartDate.Value;
                rslt.HomeCompetitorId.Value = mtch.HomeCompetitorId.Value;
                rslt.AwayCompetitorId.Value = mtch.AwayCompetitorId.Value;
                rslt.IsLiveBet.Value        = mtch.IsLiveBet.Value;
                rslt.Score.Value            = mtch.LiveMatchInfo.Score.Value;
                rslt.ExtendedState.Value    = string.Empty;
                rslt.TeamWon                = mtch.TeamWon.Value;

                var lGroups = mtch.ParentGroups.Clone();

                GroupLn groupTournament = null;
                GroupLn groupSport      = null;
                GroupLn groupCategory   = null;

                foreach (var group in lGroups)
                {
                    if (group.Type == GroupLn.GROUP_TYPE_GROUP_T)
                    {
                        groupTournament = group;
                    }
                    else if (group.Type == GroupLn.GROUP_TYPE_SPORT)
                    {
                        groupSport = group;
                    }
                    else if (group.Type == GroupLn.GROUP_TYPE_GROUP_C)
                    {
                        groupCategory = group;
                    }
                }

                ExcpHelper.ThrowIf <RelatedLineObjectNotFoundException>(groupTournament == null, "Cannot find Tournament Group for {0} and {1}", mtch, rslt);
                ExcpHelper.ThrowIf <RelatedLineObjectNotFoundException>(groupSport == null, "Cannot find Sport Group for {0} and {1}", mtch, rslt);
                ExcpHelper.ThrowIf <RelatedLineObjectNotFoundException>(groupCategory == null, "Cannot find Category Group for {0} and {1}", mtch, rslt);

                rslt.TournamentGroupId.Value = groupTournament.GroupId;
                rslt.SportGroupId.Value      = groupSport.GroupId;
                rslt.CategoryGroupId.Value   = groupCategory.GroupId;

                LineSr.Instance.AllObjects.MatchResults.MergeLineObject(rslt);
            }
            catch (Exception excp)
            {
                m_logger.Excp(excp, "MergeMatchResult ERROR for {0}", mtch);
            }
        }
        public static void SafelyApplyChanges <T>(SyncList <T> lSource, SyncObservableCollection <T> collTarget)
        {
            ExcpHelper.ThrowIf <InvalidOperationException>(ViewObjectBase.Dispatcher == null, "SafelyApplyChanges<{0}> ERROR", typeof(T).Name);

            if (!ViewObjectBase.Dispatcher.CheckAccess())
            {
                ViewObjectBase.Dispatcher.Invoke(new DelegateSafelyApplyChanges <T>(SafelyApplyChanges), lSource, collTarget);
            }
            else
            {
                collTarget.ApplyChanges(lSource);
            }
        }
Beispiel #25
0
        public static MapItem FromXmlElement(XmlElement el)
        {
            MapItem mi = new MapItem();

            mi.Tag     = el.GetAttribute("tag");
            mi.Name    = el.GetAttribute("name");
            mi.Generic = el.GetAttribute("generic");

            ExcpHelper.ThrowIf(string.IsNullOrEmpty(mi.Tag), "tag node is not set.");
            ExcpHelper.ThrowIf(string.IsNullOrEmpty(mi.Name), "name node is not set.");

            return(mi);
        }
Beispiel #26
0
        public static SportRadar.Common.Logs.ILog CreateLog(Type classType)
        {
            switch (CURRENT_LOG_TYPE)
            {
            //case eLogType.Log4Net: return new Log4NetEnvelope(classType);
            case eLogType.NLogger:
                return(new NLoggerEnvelope(classType));

            case eLogType.None: ExcpHelper.ThrowIf(true, "LogFactory.CreateLog(classType='{0}') ERROR: Please specify Log Type.", classType);

            default: ExcpHelper.ThrowIf(true, "LogFactory.CreateLog(classType='{0}') ERROR: Missed Log Type {1}", classType, CURRENT_LOG_TYPE);
            }
        }
Beispiel #27
0
        private static SerializableProperty CreateSerializableProperty(Type propertyType, string sPropertyName, object oValue, bool bIsSpecified)
        {
            DelegateCreateSerializableProperty dcsp = diSerializablePropertyFactory.SafelyGetValue(propertyType);

            ExcpHelper.ThrowIf(dcsp == null, "CreateSerializableProperty({0}, '{1}') ERROR", propertyType, sPropertyName);

            SerializableProperty sp = dcsp();

            sp.PropertyName  = sPropertyName;
            sp.PropertyValue = oValue;
            sp.IsSpecified   = bIsSpecified;

            return(sp);
        }
        public static string GetDatabaseName(string sConnectionString)
        {
            if (!string.IsNullOrEmpty(sConnectionString))
            {
                const int PAIR_COUNT = 2;

                string sDbParamName = string.Empty;

                switch (ConnectionManager.Dialect)
                {
                case DatabaseDialect.MySql:
                case DatabaseDialect.MsSql:
                case DatabaseDialect.PgSql:

                    sDbParamName = "database";
                    break;

#if SQLite
                    sDbParamName = "Data Source";
                    break;
#endif

                default:

                    Debug.Assert(false);
                    break;
                }

                Debug.Assert(!string.IsNullOrEmpty(sDbParamName));

                string[] arrSettings = m_sConnectionString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string sSetting in arrSettings)
                {
                    if (sSetting.StartsWith(sDbParamName, StringComparison.OrdinalIgnoreCase))
                    {
                        string[] arrPair = sSetting.Split(new char[] { '=', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                        ExcpHelper.ThrowIf(arrPair.Length != PAIR_COUNT, "GetDatabaseName() ERROR. Incorrect pait count ({0}) in '{1}'", arrPair.Length, sSetting);

                        return(arrPair[1]);
                    }
                }
            }

            return(null);
        }
Beispiel #29
0
        public static void Initialize()
        {
            switch (CURRENT_LOG_TYPE)
            {
            case eLogType.Log4Net:

                //log4net.Config.XmlConfigurator.Configure();
                break;

            case eLogType.NLogger:
                break;

            case eLogType.None: ExcpHelper.ThrowIf(true, "LogFactory.Initialize() ERROR: Please specify Log Type.");

            default: ExcpHelper.ThrowIf(true, "LogFactory.Initialize() ERROR: Missed Log Type {0}", CURRENT_LOG_TYPE);
            }
        }
Beispiel #30
0
        public static void DropDatabase(bool isTestMode)
        {
            string sDatabaseName     = ConfigurationManager.AppSettings["database_name"];
            string sConnectionString = ConfigurationManager.AppSettings["database_connection_string"];

            if (isTestMode)
            {
                sConnectionString.Replace(sDatabaseName, "test_" + sDatabaseName);
                sDatabaseName = "test_" + sDatabaseName;
            }

            try
            {
                using (IDbConnection conn = new NpgsqlConnection(sConnectionString.Replace(sDatabaseName, ConnectionManager.SystemDatabaseName)))
                {
                    //conn.Open();

                    eExistResult eerDatabase = DatabaseManager.DoesDatabaseExist(conn, sDatabaseName);
                    ExcpHelper.ThrowIf(eerDatabase == eExistResult.Error, "Cannot recognize if database '{0}' exists.", sDatabaseName);

                    if (eerDatabase == eExistResult.Exists)
                    {
                        try
                        {
                            DataCopy.ExecuteScalar(conn, null, "select pg_terminate_backend(procpid) from pg_stat_activity where datname='{0}';", sDatabaseName);
                            using (IDbConnection conn2 = new NpgsqlConnection(sConnectionString.Replace(sDatabaseName, ConnectionManager.SystemDatabaseName)))
                            {
                                DataCopy.ExecuteScalar(conn2, null, DatabaseManager.Schema.DeleteDatabaseStatement, sDatabaseName);
                            }
                            m_logger.InfoFormat("Database '{0}' Successfully deleted", sDatabaseName);
                        }
                        catch (Exception excp)
                        {
                            m_logger.Error(ExcpHelper.FormatException(excp, "EnsureDatabase() ERROR - cannot delete {0} Database '{1}'", ConnectionManager.Dialect, sDatabaseName), excp);
                            throw;
                        }
                    }
                }
            }
            catch (System.Exception excpInner)
            {
                string sError = string.Format("Cannot verify PostGreSQL Server. Either Server is not installed or invalid priveleges ({0}).\r\n{1}\r\n{2}", sConnectionString, excpInner.Message, excpInner.StackTrace);
                //MessageBox.Show(sError, "Station Start Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new Exception(sError, excpInner);
            }
        }