Пример #1
0
        private static RaidData GetReuquestedData(int index, int instanceid, int uploaderid)
        {
            int timeout = 0;

            while (IsRequeusted(index, instanceid, uploaderid))
            {
                Thread.Sleep(200);
                timeout += 200;
                if (timeout > 10000)
                {
                    return(null);
                }
            }

            CachingController.RegisterRaidData(instanceid, index);
            if (uploaderid > 0)
            {
                return(m_RaidData[index][instanceid][uploaderid]);
            }
            return(m_RaidData[index][instanceid].First().Value);
        }
Пример #2
0
        public static RaidData GetRaidData(int _RSInstanceID, int _RSUploaderID = 0, bool _PostVanilla = false)
        {
            var index = _PostVanilla ? 1 : 0;

            if (IsRequeusted(index, _RSInstanceID, _RSUploaderID))
            {
                var data = GetReuquestedData(index, _RSInstanceID, _RSUploaderID);
                if (data != null) // To integrate the timeout
                {
                    return(data);
                }
            }

            var tempDB = App.GetDB(index + 1);

            if (m_RaidData[index].ContainsKey(_RSInstanceID))
            {
                if (m_RaidData[index][_RSInstanceID].ContainsKey(_RSUploaderID))
                {
                    CachingController.RegisterRaidData(_RSInstanceID, index);
                    return(m_RaidData[index][_RSInstanceID][_RSUploaderID]);
                }

                if (_RSUploaderID > 0)
                {
                    MySqlDataReader dr = tempDB.Query("SELECT a.instanceid, a.guildid, a.start, a.end, b.lookupspace, a.id FROM rs_instances a LEFT JOIN rs_instance_uploader b ON a.id = b.instanceid WHERE b.id=" + _RSUploaderID).ExecuteReaderRpll();
                    if (dr.Read())
                    {
                        m_RaidData[index][_RSInstanceID][_RSUploaderID] = new RaidData(dr.GetInt32(0), dr.GetInt32(1), dr.GetInt64(2), dr.GetInt64(3), dr.GetString(4), dr.GetInt32(5), _RSUploaderID, index);
                        dr.CloseRpll();
                        CachingController.RegisterRaidData(_RSInstanceID, index);
                        return(m_RaidData[index][_RSInstanceID][_RSUploaderID]);
                    }
                    dr.CloseRpll();
                }

                CachingController.RegisterRaidData(_RSInstanceID, index);

                // Take the first non private log
                var LogInfo = App.mRSInstances[index].Where(x => x.mId == _RSInstanceID).First();
                if (LogInfo != null)
                {
                    var sth = m_Uploader[_RSInstanceID]
                              .Where(x => LogInfo.mPrivate.Where(y => !y.Value && y.Key == x.Key).Count() >= 1).ToArray();
                    if (sth.Length > 0)
                    {
                        if (m_RaidData[index][_RSInstanceID].ContainsKey(sth[0].Key))
                        {
                            return(m_RaidData[index][_RSInstanceID][sth[0].Key]);
                        }
                    }
                }

                try { HttpContext.Current.Response.Redirect("/Private/", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
                return(null);
            }
            MySqlDataReader drr = tempDB.Query("SELECT b.id, a.instanceid, a.guildid, a.start, a.end, b.lookupspace, a.id FROM rs_instances a LEFT JOIN rs_instance_uploader b ON a.id = b.instanceid WHERE a.id=" + _RSInstanceID).ExecuteReaderRpll();
            ConcurrentDictionary <int, RaidData> newData = new ConcurrentDictionary <int, RaidData>();

            var LogInfo2 = App.mRSInstances[index].Where(x => x.mId == _RSInstanceID).First();

            while (!drr.IsClosed && drr.Read()) // ?!
            {
                if (LogInfo2 != null)
                {
                    if (LogInfo2.mPrivate.Where(y => y.Value && y.Key == drr.GetInt32(0)).Count() >= 1)
                    {
                        continue;
                    }
                }

                newData[drr.GetInt32(0)] = new RaidData(drr.GetInt32(1), drr.GetInt32(2), drr.GetInt64(3), drr.GetInt64(4), drr.GetString(5), drr.GetInt32(6), drr.GetInt32(0), index);
                break; // Just load first one!
            }
            drr.CloseRpll();
            m_RaidData[index][_RSInstanceID] = newData;
            CachingController.RegisterRaidData(_RSInstanceID, index);

            // Take the first non private log
            if (LogInfo2 != null)
            {
                var sth2 = m_Uploader[_RSInstanceID]
                           .Where(x => LogInfo2.mPrivate.Where(y => !y.Value && y.Key == x.Key).Count() >= 1).ToArray();
                if (sth2.Length > 0)
                {
                    if (m_RaidData[index][_RSInstanceID].ContainsKey(sth2[0].Key))
                    {
                        return(m_RaidData[index][_RSInstanceID][sth2[0].Key]);
                    }
                }
            }

            try { HttpContext.Current.Response.Redirect("/Private/", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return(null);
        }