Example #1
0
        public virtual OutputQueueData[] getAllOutputQueueData()
        {
            System.Collections.ArrayList ary = new System.Collections.ArrayList();

            if (outputQueue.Count == 0)
                return null;
            else
            {

                System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
                while (ie.MoveNext())
                {
                    OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                    ary.Add(quedata);

                }
            }

            ary.Sort();
            object[] data = ary.ToArray();

            OutputQueueData[] retobjs = new OutputQueueData[data.Length];

            for (int i = 0; i < data.Length; i++)
                retobjs[i] =(OutputQueueData)data[i];

            return retobjs;
        }
Example #2
0
        public static void qualhtmlResult(System.Collections.Hashtable raceStat, string datFile, string qualDir, infoRace currInfoRace, int maxTimeQualIgnore )
        {
            long firstTotalTime = 0;
            int curPos;
            wr.wrInfo wi;

            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];
                p.tmpTime = 0;
            }
            // Remove Lap over then x percent of bestlaptime
            for (int i = 0; i < sorted.Count; i++)
            {

                raceStats p = (raceStats)sorted[i];
                int idx;
                long maxTime = (int)((double)p.bestLap * ((double)1 + ((double)maxTimeQualIgnore / (double)100)));
            // Remove Lap over then x percent of bestlaptime
                for (idx = p.lap.Count - 1; idx >= 0; idx--)
                {
                    if ((p.lap[idx] as Lap).lapTime > maxTime )
                    {

                        System.Console.WriteLine("Remove " + raceStats.LfstimeToString((p.lap[idx] as Lap).lapTime)
                                    + " Best : " + raceStats.LfstimeToString(p.bestLap)
                                    + " Reference : " + raceStats.LfstimeToString(maxTime)
                        );
                        p.lap.RemoveAt(idx);
                    }
                }
            // Recalc Split,cumuled Time and Lap of bestlap due to remove time under bestlap + X percent of bestLap
                p.cumuledTime = 0;
                if (p.lap.Count != 0)
                {
                    for (idx = 0; idx < p.lap.Count; idx++)
                    {
                        p.cumuledTime += (p.lap[idx] as Lap).lapTime;
                        if (p.bestLap == (p.lap[idx] as Lap).lapTime)
                            p.lapBestLap = idx + 1;
                    }
                }
            }
            // CALC avg
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];
                try
                {
                    if (p.lap.Count != 0)
                        p.avgTime = p.cumuledTime / p.lap.Count;
                }
                catch
                {
                    p.avgTime = 0;
                }
            }
            // CALC lapStability
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];

                if (p.avgTime == 0)
                {
                    p.lapStability = -1;
                    continue;
                }
                for (int j = 0; j < p.lap.Count; j++)
                {
                    p.lapStability += System.Math.Pow((double)(p.avgTime - (p.lap[j] as Lap).lapTime), 2);
                }
                if (p.lap.Count > 1)
                    p.lapStability = System.Math.Sqrt(p.lapStability / ((p.lap.Count) - 1));
                else
                    p.lapStability = -1;
            }
            System.IO.StreamWriter sw = new System.IO.StreamWriter(qualDir + "/" + datFile + "_results_qual.html");
            System.IO.StreamReader sr = new System.IO.StreamReader("./templates/html_qual.tpl");
            string readLine;
            combinedSplit = 0;

            while (true)
            {
                readLine = sr.ReadLine();
                if (readLine == null)
                    break;
                if (readLine.IndexOf("[QualResults") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BESTLAP;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];
                        if (p.bestLap == 0)
                            continue;
                        curPos++;
                        string lnickname = lfsColorToHtml(p.nickName);
                        wreadLine = wreadLine.Replace("[QualResults ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        p.finalPos = curPos;
                        wreadLine = wreadLine.Replace("{Position}", p.finalPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerNameColoured}", lnickname);
                        wreadLine = wreadLine.Replace("{UserNameLink}", p.userName);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{Car}", p.CName);
                        wreadLine = wreadLine.Replace("{NumberPlate}", lfsStripColor(p.Plate));

                        wreadLine = wreadLine.Replace("{BestLap}", raceStats.LfstimeToString(p.bestLap));
                        if (curPos == 1)
                        {
                            firstTotalTime = p.bestLap;
                        }
                        long tres;
                        tres = p.bestLap - firstTotalTime;
                        wreadLine = wreadLine.Replace("{Difference}", "+" + raceStats.LfstimeToString(tres));
                        wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                        if (wi == null)
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.bestLap - wi.WRTime));
                        wreadLine = wreadLine.Replace("{BestLapLap}", p.lapBestLap.ToString() );
                        wreadLine = wreadLine.Replace("{LapsDone}", p.lap.Count.ToString());

                        wreadLine = wreadLine.Replace("{Flags}", p.sFlags);
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[LapTimesStability") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_STABILITY;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    double baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.lapStability <= 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[LapTimesStability ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.lapStability;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{Deviation}", raceStats.LfstimeToString((long)p.lapStability));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString((long)(p.lapStability - baseTime)));
                        wreadLine = wreadLine.Replace("{LapsDone}", p.lap.Count.ToString());

                        sw.WriteLine(wreadLine);
                    }
                    continue;

                }

                if (readLine.IndexOf("[AverageLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_AVGTIME;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.avgTime == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[AverageLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.avgTime;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.avgTime));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.avgTime - baseTime));
                        wreadLine = wreadLine.Replace("{Laps}", p.lap.Count.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }

                if (readLine.IndexOf("[BestLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BESTLAP;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.bestLap == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[BestLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.bestLap;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.bestLap));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.bestLap - baseTime));
                        wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                        if (wi == null)
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.bestLap - wi.WRTime));
                        wreadLine = wreadLine.Replace("{Lap}", p.lapBestLap.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[[BestSplitTable") == 0)
                {
                    System.Collections.ArrayList blockSplit = new System.Collections.ArrayList();
                    blockSplit.Add(readLine);
                    while (true)
                    {
                        readLine = sr.ReadLine();
                        if (readLine == null)
                            break;
                        if (readLine.IndexOf("]]") != -1)
                        {
                            blockSplit.Add(readLine);
                            break;
                        }
                        blockSplit.Add(readLine);
                    }
                    for (int j = 0; j <= currInfoRace.maxSplit; j++)
                    {
                        for (int i = 0; i < sorted.Count; i++)
                        {
                            raceStats p = (raceStats)sorted[i];
                            wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                            if (j == currInfoRace.maxSplit)
                            {
                                p.curBestSplit = p.bestLastSplit;
                                p.curLapBestSplit = p.lapBestLastSplit;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplitLast;
                                continue;
                            }
                            if (j == 0)
                            {
                                p.curBestSplit = p.bestSplit1;
                                p.curLapBestSplit = p.lapBestSplit1;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                            if (j == 1)
                            {
                                p.curBestSplit = p.bestSplit2;
                                p.curLapBestSplit = p.lapBestSplit2;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                            if (j == 2)
                            {
                                p.curBestSplit = p.bestSplit3;
                                p.curLapBestSplit = p.lapBestSplit3;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                        }
                        for (int k = 0; k < blockSplit.Count; k++)
                        {
                            readLine = (string)blockSplit[k];
                            if (readLine.IndexOf("[BestSplit") == 0)
                            {
                                raceStats.modeSort = (int)sortRaceStats.SORT_BESTSPLIT;
                                sorted.Sort();
                                string wreadLine;
                                curPos = 0;
                                long baseTime = 0;
                                for (int i = 0; i < sorted.Count; i++)
                                {
                                    raceStats p = (raceStats)sorted[i];

                                    wreadLine = readLine;
                                    if (p.curBestSplit == 0)
                                        continue;
                                    string lnickname = lfsStripColor(p.nickName);
                                    wreadLine = wreadLine.Replace("[BestSplit ", "");
                                    wreadLine = wreadLine.Replace("]", "");
                                    curPos++;
                                    if (curPos == 1)
                                        baseTime = p.curBestSplit;
                                    wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                                    wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                                    wreadLine = wreadLine.Replace("{UserName}", p.userName);
                                    wreadLine = wreadLine.Replace("{SplitTime}", raceStats.LfstimeToString(p.curBestSplit));
                                    wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.curBestSplit - baseTime));
                                    if (p.curWrSplit == 0)
                                        wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                                    else
                                        wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.curBestSplit - p.curWrSplit));
                                    wreadLine = wreadLine.Replace("{Lap}", p.curLapBestSplit.ToString());
                                    sw.WriteLine(wreadLine);
                                }
                                combinedSplit = combinedSplit + baseTime;
                                continue;
                            }
                            readLine = updateGlob(readLine, datFile, currInfoRace, "qual");
                            readLine = readLine.Replace("]]", "");
                            readLine = readLine.Replace("[[BestSplitTable ", "");
                            readLine = readLine.Replace("{SplitNumber}", (j + 1).ToString());
                            sw.WriteLine(readLine);
                        }
                    }
                }
                if (readLine.IndexOf("[BestPossibleLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_TPB;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if ((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[BestPossibleLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) - baseTime));
                        wreadLine = wreadLine.Replace("{DifferenceToBestLap}", raceStats.LfstimeToString((p.bestLap - p.bestSplit1 - p.bestSplit2 - p.bestSplit3 - p.bestLastSplit)));
                        wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                        if (wi == null)
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) - wi.WRTime));
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[BlueFlagCausers") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BLUEFLAG;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.blueFlags == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[BlueFlagCausers ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{BlueFlagsCount}", p.blueFlags.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[YellowFlagCausers") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_YELLOWFLAG;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.yellowFlags == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[YellowFlagCausers ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{YellowFlagsCount}", p.yellowFlags.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[PitStops") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_PIT;
                    sorted.Sort();
                    string wreadLine;
                    string pitinfo = "";
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[PitStops ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        pitinfo = "";
                        string br = "";
                        string virg = "";
                        string SWork = "";
                        for (int j = 0; j < p.pit.Count; j++)
                        {
                            SWork = "{lg_lap} " + ((p.pit[j] as Pit).LapsDone + 1) + ":";
                            //                            SWork = (p.pit[j] as Pit).Work + "{lg_lap} " + ((p.pit[j] as Pit).LapsDone + 1) + ":";
                            if (isBitSet((p.pit[j] as Pit).Work, 1) == true)
                            {
                                SWork = SWork + virg + " {lg_stop}";
                                virg = ", ";
                            }
                            if (isBitSet((p.pit[j] as Pit).Work, 14) == true)
                            {
                                SWork = SWork + virg + " {lg_minor}";
                                virg = ", ";
                            }
                            if (isBitSet((p.pit[j] as Pit).Work, 15) == true)
                            {
                                SWork = SWork + virg + "{lg_major}";
                                virg = ", ";
                            }
                            if (isBitSet((p.pit[j] as Pit).Work, 17) == true)
                            {
                                SWork = SWork + virg + "{lg_refuel}";
                                virg = ", ";
                            }
                            if ((p.pit[j] as Pit).STime != 0)
                                SWork = SWork + virg + "{lg_start}";
                            SWork = updateGlob(SWork, datFile, currInfoRace, "qual");
                            pitinfo = pitinfo + br + SWork + " (" + raceStats.LfstimeToString((p.pit[j] as Pit).STime) + ")";
                            br = "<BR>";
                        }
                        wreadLine = wreadLine.Replace("{PitInfo}", pitinfo);
                        wreadLine = wreadLine.Replace("{PitTime}", raceStats.LfstimeToString(p.cumuledStime));
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[TopSpeed") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BESTSPEED;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    int baseSpeed = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.bestSpeed == 0)
                            continue;
                        string lnickname = lfsStripColor(p.nickName);
                        wreadLine = wreadLine.Replace("[TopSpeed ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseSpeed = p.bestSpeed;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{TopSpeed}", raceStats.LfsSpeedToString(p.bestSpeed));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfsSpeedToString(baseSpeed - p.bestSpeed));
                        wreadLine = wreadLine.Replace("{TopSpeedLap}", p.lapBestSpeed.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }

                readLine = updateGlob(readLine, datFile, currInfoRace, "qual");
                sw.WriteLine(readLine);
            }
            sw.Close();
            sr.Close();
        }
Example #3
0
        public override OutputQueueData getOutputdata()
        {
            System.Collections.ArrayList ary = new System.Collections.ArrayList();
               byte[] laneids = new byte[] { 1, 2, 3 };
               object[] displays = new object[3];
               //    byte  [] speedllimits = new byte[] { -1,-1,-1,-1,-1,-1};
               OutputQueueData ret;

               if (outputQueue.Count == 0)
               return null;
               else
               {

               System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
               while (ie.MoveNext())
               {
                   OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                   ary.Add(quedata);

               }
               }

               ary.Sort();
               if (ary.Count == 0)
               return null;
               else if (ary.Count == 1)
               {
               RemoteInterface.HC.MASOutputData data = (MASOutputData)((OutputQueueData)ary[ary.Count - 1]).data;

               for (int i = 0; i < data.laneids.Length; i++)
               {
                   laneids[data.laneids[i] - 1] = data.laneids[i];
                   displays[data.laneids[i] - 1] = data.displays[i];
                 //  colors[data.boardid[i] - 1] = data.color[i];
               }

               }
               else
               {
               RemoteInterface.HC.MASOutputData data = (MASOutputData)((OutputQueueData)ary[ary.Count - 2]).data;

               for (int i = 0; i < data.laneids.Length; i++)
               {
                   laneids[data.laneids[i] - 1] = data.laneids[i];
                   displays[data.laneids[i] - 1] = data.laneids[i];
                   //colors[data.boardid[i] - 1] = data.color[i];
               }
               data = (MASOutputData)((OutputQueueData)ary[ary.Count - 1]).data;
               for (int i = 0; i < data.laneids.Length; i++)
               {
                   laneids[data.laneids[i] - 1] = data.laneids[i];
                   displays[data.laneids[i] - 1] = data.displays[i];
                  // colors[data.boardid[i] - 1] = data.color[i];
               }
               }

               ret = new OutputQueueData(this.deviceName,((OutputQueueData)ary[ary.Count - 1]).mode, ((OutputQueueData)ary[ary.Count - 1]).ruleid, ((OutputQueueData)ary[ary.Count - 1]).priority
               , new MASOutputData(laneids, displays));
               return ret;
        }
Example #4
0
        private void ResortToolStripItemCollection(ToolStripItemCollection coll)
        {
            System.Collections.ArrayList oAList = new System.Collections.ArrayList(coll);
            oAList.Sort(new ToolStripItemComparer());
            coll.Clear();

            foreach (ToolStripItem oItem in oAList)
            {
                coll.Add(oItem);
            }
        }
Example #5
0
        /* Fringe Search
         * Fringe search is a memory enchanced version of IDA* */
        public bool fringeSearch()
        {
            //initialize:
            System.Collections.ArrayList nowList      = new System.Collections.ArrayList();
            System.Collections.ArrayList laterList    = new System.Collections.ArrayList();
            System.Collections.ArrayList rejectedList = new System.Collections.ArrayList();
            int limit = calcHvalue(startNode);

           #if DEBUG
            Globals.l2net_home.Add_Debug("start limit:" + limit);
           #endif

            bool found = false;

            Globals.debugPath = nowList;
            nowList.Add(startNode);

            while (!found)
            {
                // Globals.l2net_home.Add_Debug("big loop...");

                int fmin = INFINITY;
                while (nowList.Count != 0)
                {
                    AstarNode head = ((AstarNode)nowList[0]);
                    head.fvalue = calcFvalue(head);


                    #region check for goal
                    if (isNodeTarget(head, targetNode.x, targetNode.y))
                    {
                        found = true;
                        break;
                    }
                    #endregion

                    //check if head is over the limit
                    if (head.fvalue > limit)
                    {
                        //transfer head from nowlist to laterlist.
                        nowList.Remove(head);
                        laterList.Add(head);

                        //find the minimum of the nodes we will look at 'later'
                        fmin = Util.MIN(fmin, head.fvalue);
                    }
                    else
                    {
                        #region expand head's children on to now list
                        expand(head); //nodes are sorted by insert sort in this function

                        bool addedChildren = false;
                        foreach (AstarNode child in head.adjacentNodes)
                        {
                            //dont allow children already on path or adjacent to path or walls...

                            if (!isNodeIn(nowList, child) && !isNodeIn(laterList, child) && !isNodeIn(rejectedList, child))
                            {
                                if (child.passable == true)
                                {
                                    //add child of head to front of nowlist
                                    nowList.Insert(0, child);
                                    addedChildren = true;
                                }
                            }
                        }
                        if (!addedChildren)
                        {
                            nowList.Remove(head);
                            rejectedList.Add(head);
                        }
                        #endregion
                    }
                }
                if (found == true)
                {
                    break;
                }

                //set new limit
                // Globals.l2net_home.Add_Debug("new limit:" + fmin);
                limit = fmin;

                //set now list to later list.
                nowList = (System.Collections.ArrayList)laterList.Clone();
                nowList.Sort();
                Globals.debugPath = nowList;
                laterList.Clear();
            }

            if (found == true)
            {
#if DEBUG
                Globals.l2net_home.Add_Debug("found a path... building...");
#endif
                buildPathFromParents(((AstarNode)nowList[0]));
                return(true);
            }

            return(false);
        }
        /// <summary> Write a HibernateMapping XML Element from attributes in a type. </summary>
        public virtual void WriteHibernateMapping(System.Xml.XmlWriter writer, System.Type type)
        {
            object[] attributes = type.GetCustomAttributes(typeof(HibernateMappingAttribute), false);
            if(attributes.Length == 0)
                return;
            HibernateMappingAttribute attribute = attributes[0] as HibernateMappingAttribute;

            writer.WriteStartElement( "hibernate-mapping" );
            // Attribute: <schema>
            if(attribute.Schema != null)
            writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, type));
            // Attribute: <catalog>
            if(attribute.Catalog != null)
            writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, type));
            // Attribute: <default-cascade>
            if(attribute.DefaultCascade != null)
            writer.WriteAttributeString("default-cascade", GetAttributeValue(attribute.DefaultCascade, type));
            // Attribute: <default-access>
            if(attribute.DefaultAccess != null)
            writer.WriteAttributeString("default-access", GetAttributeValue(attribute.DefaultAccess, type));
            // Attribute: <default-lazy>
            if( attribute.DefaultLazySpecified )
            writer.WriteAttributeString("default-lazy", attribute.DefaultLazy ? "true" : "false");
            // Attribute: <auto-import>
            if( attribute.AutoImportSpecified )
            writer.WriteAttributeString("auto-import", attribute.AutoImport ? "true" : "false");
            // Attribute: <namespace>
            if(attribute.Namespace != null)
            writer.WriteAttributeString("namespace", GetAttributeValue(attribute.Namespace, type));
            // Attribute: <assembly>
            if(attribute.Assembly != null)
            writer.WriteAttributeString("assembly", GetAttributeValue(attribute.Assembly, type));

            WriteUserDefinedContent(writer, type, null, attribute);
            // Element: <meta>
            System.Collections.ArrayList MetaList = FindAttributedMembers( attribute, typeof(MetaAttribute), type );
            foreach( System.Reflection.MemberInfo member in MetaList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MetaAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MetaAttribute), attribute);
            // Element: <typedef>
            System.Collections.ArrayList TypeDefList = FindAttributedMembers( attribute, typeof(TypeDefAttribute), type );
            foreach( System.Reflection.MemberInfo member in TypeDefList )
            {
                object[] objects = member.GetCustomAttributes(typeof(TypeDefAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteTypeDef(writer, member, memberAttrib as TypeDefAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(TypeDefAttribute), attribute);
            // Element: <import>
            WriteNestedImportTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(ImportAttribute), attribute);
            // Element: <class>
            WriteNestedClassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(ClassAttribute), attribute);
            // Element: <subclass>
            WriteNestedSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(SubclassAttribute), attribute);
            // Element: <joined-subclass>
            WriteNestedJoinedSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(JoinedSubclassAttribute), attribute);
            // Element: <union-subclass>
            WriteNestedUnionSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(UnionSubclassAttribute), attribute);
            // Element: <resultset>
            System.Collections.ArrayList ResultSetList = FindAttributedMembers( attribute, typeof(ResultSetAttribute), type );
            foreach( System.Reflection.MemberInfo member in ResultSetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ResultSetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteResultSet(writer, member, memberAttrib as ResultSetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ResultSetAttribute), attribute);
            // Element: <query>
            System.Collections.ArrayList QueryList = FindAttributedMembers( attribute, typeof(QueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in QueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(QueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteQuery(writer, member, memberAttrib as QueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(QueryAttribute), attribute);
            // Element: <sql-query>
            System.Collections.ArrayList SqlQueryList = FindAttributedMembers( attribute, typeof(SqlQueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlQueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlQueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlQuery(writer, member, memberAttrib as SqlQueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlQueryAttribute), attribute);
            // Element: <filter-def>
            System.Collections.ArrayList FilterDefList = FindAttributedMembers( attribute, typeof(FilterDefAttribute), type );
            foreach( System.Reflection.MemberInfo member in FilterDefList )
            {
                object[] objects = member.GetCustomAttributes(typeof(FilterDefAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteFilterDef(writer, member, memberAttrib as FilterDefAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(FilterDefAttribute), attribute);
            // Element: <database-object>
            System.Collections.ArrayList DatabaseObjectList = FindAttributedMembers( attribute, typeof(DatabaseObjectAttribute), type );
            foreach( System.Reflection.MemberInfo member in DatabaseObjectList )
            {
                object[] objects = member.GetCustomAttributes(typeof(DatabaseObjectAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteDatabaseObject(writer, member, memberAttrib as DatabaseObjectAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(DatabaseObjectAttribute), attribute);

            writer.WriteEndElement();
        }
		// TODO: would be nice to factor out more of this, eg the
		// FreqProxFieldMergeState, and code to visit all Fields
		// under the same FieldInfo together, up into TermsHash*.
		// Other writers would presumably share alot of this...
		
		public override void  Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state)
		{
			
			// Gather all FieldData's that have postings, across all
			// ThreadStates
			System.Collections.ArrayList allFields = new System.Collections.ArrayList();

            System.Collections.IEnumerator it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
			while (it.MoveNext())
			{
				
				System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
				
				System.Collections.ICollection fields = (System.Collections.ICollection) entry.Value;
				
				System.Collections.IEnumerator fieldsIt = fields.GetEnumerator();
				
				while (fieldsIt.MoveNext())
				{
					FreqProxTermsWriterPerField perField = (FreqProxTermsWriterPerField) ((System.Collections.DictionaryEntry) fieldsIt.Current).Key;
					if (perField.termsHashPerField.numPostings > 0)
						allFields.Add(perField);
				}
			}
			
			// Sort by field name
            allFields.Sort();
			int numAllFields = allFields.Count;
			
			// TODO: allow Lucene user to customize this consumer:
			FormatPostingsFieldsConsumer consumer = new FormatPostingsFieldsWriter(state, fieldInfos);
			/*
			Current writer chain:
			FormatPostingsFieldsConsumer
			-> IMPL: FormatPostingsFieldsWriter
			-> FormatPostingsTermsConsumer
			-> IMPL: FormatPostingsTermsWriter
			-> FormatPostingsDocConsumer
			-> IMPL: FormatPostingsDocWriter
			-> FormatPostingsPositionsConsumer
			-> IMPL: FormatPostingsPositionsWriter
			*/
			
			int start = 0;
			while (start < numAllFields)
			{
				FieldInfo fieldInfo = ((FreqProxTermsWriterPerField) allFields[start]).fieldInfo;
				System.String fieldName = fieldInfo.name;
				
				int end = start + 1;
				while (end < numAllFields && ((FreqProxTermsWriterPerField) allFields[end]).fieldInfo.name.Equals(fieldName))
					end++;
				
				FreqProxTermsWriterPerField[] fields = new FreqProxTermsWriterPerField[end - start];
				for (int i = start; i < end; i++)
				{
					fields[i - start] = (FreqProxTermsWriterPerField) allFields[i];
					
					// Aggregate the storePayload as seen by the same
					// field across multiple threads
					fieldInfo.storePayloads |= fields[i - start].hasPayloads;
				}
				
				// If this field has postings then add them to the
				// segment
				AppendPostings(fields, consumer);
				
				for (int i = 0; i < fields.Length; i++)
				{
					TermsHashPerField perField = fields[i].termsHashPerField;
					int numPostings = perField.numPostings;
					perField.Reset();
					perField.ShrinkHash(numPostings);
					fields[i].Reset();
				}
				
				start = end;
			}

            it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
			while (it.MoveNext())
			{
				System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
				FreqProxTermsWriterPerThread perThread = (FreqProxTermsWriterPerThread) entry.Key;
				perThread.termsHashPerThread.Reset(true);
			}
			
			consumer.Finish();
		}
        public static void csvAllResult(System.Collections.Hashtable raceStat, string datFile, infoRace currInfoRace)
        {
            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            raceStats.modeSort = (int)sortRaceStats.SORT_RESULT;
            sorted.Sort();

            if(!Directory.Exists("Export"))
                System.IO.Directory.CreateDirectory("Export");

            var raceEngine = new DelimitedFileEngine<infoRace>();
            raceEngine.HeaderText = "datFile,currentTrackName,maxSplit,weather,wind,raceLaps,sraceLaps,qualMins,HName,currLap,isToc";
            var raceResults = new List<infoRace>();
            currInfoRace.datFile = datFile;
            raceResults.Add(currInfoRace);
            raceEngine.WriteFile("Export/" + datFile + "_race.csv", raceResults);

            var engine = new DelimitedFileEngine<raceStats>();
            engine.HeaderText = "datFile,UCID,PLID,userName,nickName,Plate,bestSplit1,lapBestSplit1,bestSplit2,lapBestSplit2,bestSplit3,lapBestSplit3,bestLastSplit,lapBestLastSplit,cumuledTime,bestSpeed,lapBestSpeed,numStop,cumuledStime,resultNum,finalPos,finished,finPLID,totalTime,bestLap,lapBestLap,CName,penalty,gridPos,lapsLead,tmpTime,firstTime,avgTime,curBestSplit,curWrSplit,curLapBestSplit,lapStability,curSplit1,curSplit2,curSplit3,yellowFlags,inYellow,blueFlags,inBlue,sFlags,numPen,lastSplit,CurrIdxSplit";

            List<raceStats> results = new List<raceStats>();
            foreach (raceStats r in sorted)
            {
                r.datFile = datFile;
                results.Add(r);
            }

            engine.WriteFile("Export/" + datFile + "_results_race.csv", results);

            List<Lap> lapResults = new List<Lap>();
            foreach (raceStats r in sorted)
            {
                int i = 1;
                foreach (Lap lap in r.lap)
                {
                    lap.datFile = datFile;
                    lap.UCID = r.UCID;
                    lap.PLID = r.PLID;
                    lap.lap = i++;
                    lapResults.Add((Lap)lap);
                }
            }

            var engine2 = new DelimitedFileEngine<Lap>();
            engine2.HeaderText = "datFile,UCID,PLID,lap,split1,split2,split3,lapTime,cumuledTime";
            engine2.WriteFile("Export/" + datFile + "_results_race_laps.csv", lapResults);

            ////this.ContentTypeFilters.Register(ContentType.Csv, CsvSerializer.SerializeToStream, CsvSerializer.DeserializeFromStream);

            ////using (System.IO.StreamWriter sw = new System.IO.StreamWriter("Export/" + datFile + "_results_race.csv"))
            ////{
            //    //int curPos = 0;
            //    for (int i = 0; i < sorted.Count; i++)
            //    {

            //        raceStats p = (raceStats)sorted[i];

            //        //curPos++;
            //        //raceStats p = (raceStats)sorted[i];
            //        //if (i == 0)
            //        //{
            //        //    firstMaxLap = p.lap.Count;
            //        //    firstTotalTime = p.totalTime;
            //        //}
            //        //string resultLine = formatLine;
            //        //resultLine = resultLine.Replace("[RaceResults ", "");
            //        //resultLine = resultLine.Replace("]", "");
            //        //resultLine = resultLine.Replace("{Position}", curPos.ToString());
            //        ////                    resultLine = resultLine.Replace("{Position}", p.resultNum.ToString() );
            //        //resultLine = resultLine.Replace("{PlayerName}", p.nickName.Replace("^0", "").Replace("^1", "").Replace("^2", "").Replace("^3", "").Replace("^4", "").Replace("^5", "").Replace("^6", "").Replace("^7", "").Replace("^8", ""));
            //        //resultLine = resultLine.Replace("{UserName}", p.userName);
            //        //resultLine = resultLine.Replace("{Car}", p.CName);
            //        //// if Racer do not finish
            //        //if (p.resultNum == 999)
            //        //    resultLine = resultLine.Replace("{Gap}", "DNF");
            //        //else
            //        //{
            //        //    if (firstMaxLap == p.lap.Count)
            //        //    {
            //        //        if (i == 0)
            //        //            resultLine = resultLine.Replace("{Gap}", raceStats.LfstimeToString(p.totalTime));
            //        //        else
            //        //        {
            //        //            long tres;
            //        //            tres = p.totalTime - firstTotalTime;
            //        //            resultLine = resultLine.Replace("{Gap}", "+" + raceStats.LfstimeToString(tres));
            //        //        }
            //        //    }
            //        //    else
            //        //        resultLine = resultLine.Replace("{Gap}", "+" + ((int)(firstMaxLap - p.lap.Count)).ToString() + " laps");
            //        //}
            //        //resultLine = resultLine.Replace("{BestLap}", raceStats.LfstimeToString(p.bestLap));
            //        //resultLine = resultLine.Replace("{LapsDone}", p.lap.Count.ToString());
            //        //resultLine = resultLine.Replace("{PitsDone}", p.numStop.ToString());
            //        //resultLine = resultLine.Replace("{Penalty}", p.penalty);
            //        //resultLine = resultLine.Replace("{PosGrid}", p.gridPos.ToString());
            //        //resultLine = resultLine.Replace("{Flags}", p.sFlags);
            //        //sw.WriteLine(resultLine);
            //    }
            ////}
        }
Example #9
0
        // TODO: would be nice to factor out more of this, eg the
        // FreqProxFieldMergeState, and code to visit all Fields
        // under the same FieldInfo together, up into TermsHash*.
        // Other writers would presumably share alot of this...

        public override void  Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state)
        {
            // Gather all FieldData's that have postings, across all
            // ThreadStates
            System.Collections.ArrayList allFields = new System.Collections.ArrayList();

            System.Collections.IEnumerator it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
            while (it.MoveNext())
            {
                System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry)it.Current;

                System.Collections.ICollection fields = (System.Collections.ICollection)entry.Value;

                System.Collections.IEnumerator fieldsIt = fields.GetEnumerator();

                while (fieldsIt.MoveNext())
                {
                    FreqProxTermsWriterPerField perField = (FreqProxTermsWriterPerField)((System.Collections.DictionaryEntry)fieldsIt.Current).Key;
                    if (perField.termsHashPerField.numPostings > 0)
                    {
                        allFields.Add(perField);
                    }
                }
            }

            // Sort by field name
            allFields.Sort();
            int numAllFields = allFields.Count;

            // TODO: allow Lucene user to customize this consumer:
            FormatPostingsFieldsConsumer consumer = new FormatPostingsFieldsWriter(state, fieldInfos);

            /*
             * Current writer chain:
             * FormatPostingsFieldsConsumer
             * -> IMPL: FormatPostingsFieldsWriter
             * -> FormatPostingsTermsConsumer
             * -> IMPL: FormatPostingsTermsWriter
             * -> FormatPostingsDocConsumer
             * -> IMPL: FormatPostingsDocWriter
             * -> FormatPostingsPositionsConsumer
             * -> IMPL: FormatPostingsPositionsWriter
             */

            int start = 0;

            while (start < numAllFields)
            {
                FieldInfo     fieldInfo = ((FreqProxTermsWriterPerField)allFields[start]).fieldInfo;
                System.String fieldName = fieldInfo.name;

                int end = start + 1;
                while (end < numAllFields && ((FreqProxTermsWriterPerField)allFields[end]).fieldInfo.name.Equals(fieldName))
                {
                    end++;
                }

                FreqProxTermsWriterPerField[] fields = new FreqProxTermsWriterPerField[end - start];
                for (int i = start; i < end; i++)
                {
                    fields[i - start] = (FreqProxTermsWriterPerField)allFields[i];

                    // Aggregate the storePayload as seen by the same
                    // field across multiple threads
                    fieldInfo.storePayloads |= fields[i - start].hasPayloads;
                }

                // If this field has postings then add them to the
                // segment
                AppendPostings(fields, consumer);

                for (int i = 0; i < fields.Length; i++)
                {
                    TermsHashPerField perField = fields[i].termsHashPerField;
                    int numPostings            = perField.numPostings;
                    perField.Reset();
                    perField.ShrinkHash(numPostings);
                    fields[i].Reset();
                }

                start = end;
            }

            it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
            while (it.MoveNext())
            {
                System.Collections.DictionaryEntry entry     = (System.Collections.DictionaryEntry)it.Current;
                FreqProxTermsWriterPerThread       perThread = (FreqProxTermsWriterPerThread)entry.Key;
                perThread.termsHashPerThread.Reset(true);
            }

            consumer.Finish();
        }
        public void AddAllData(System.Collections.ArrayList al)
        {
            if (al.Count <= 0)
            {
                return;
            }

            #region 中成药、草药打印

            try
            {
                try
                {
                    ComboSort comboSort = new ComboSort();
                    al.Sort(comboSort);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("数组排序发生错误" + ex.Message);
                    return;
                }

                int iIndex = this.neuSpread1_Sheet1.Rows.Count;
                foreach (Neusoft.HISFC.Models.Pharmacy.ApplyOut info in al)
                {
                    this.neuSpread1_Sheet1.Rows.Add(iIndex, 1);
                    this.neuSpread1_Sheet1.Cells[iIndex, 0].Text = info.CombNO;                                                                                                                                                                                                   //组合号
                    this.neuSpread1_Sheet1.Cells[iIndex, 2].Text = string.Format("{0}-{1}[{2}]  {3}{4}/{5}", info.Item.Name, Function.DrugDosage.GetStaticDosage(info.Item.ID), info.Item.Specs, info.Operation.ApplyQty, info.Item.MinUnit, usageHelper.GetName(info.Usage.ID)); //药品用药信息

                    this.lbInfo.Text = string.Format("姓名:{0}        日期:{1}     病历号:{2}", info.User02, info.Operation.ApplyOper.OperTime.ToString("yyyy-MM-dd"), info.PatientNO);
                }

                int    groupID   = 0;
                string privCombo = "-1";
                for (int i = 0; i < this.neuSpread1_Sheet1.Rows.Count; i++)
                {
                    if (privCombo != this.neuSpread1_Sheet1.Cells[i, 0].Text)
                    {
                        groupID++;
                        this.neuSpread1_Sheet1.Cells[i, 1].Text = groupID.ToString();
                        privCombo = this.neuSpread1_Sheet1.Cells[i, 0].Text;
                    }
                    else
                    {
                        this.neuSpread1_Sheet1.Cells[i, 1].Text = groupID.ToString();
                    }
                }

                iIndex = this.neuSpread1_Sheet1.Rows.Count;
                this.neuSpread1_Sheet1.Rows.Add(iIndex, 2);
                iIndex = this.neuSpread1_Sheet1.Rows.Count - 1;
                this.neuSpread1_Sheet1.Cells[iIndex, 0].ColumnSpan = 7;
                this.neuSpread1_Sheet1.Cells[iIndex, 0].Text       = "发药:              核对:                 护士核对:";
                this.neuSpread1_Sheet1.Rows[iIndex].Font           = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }
Example #11
0
            ///------------------------------------------------------------------------
            /// <summary>
            ///     CSV社員マスターコンボボックスロード </summary>
            /// <param name="fName">
            ///     CSVファイル名</param>
            /// <param name="tempObj">
            ///     コンボボックス</param>
            /// <param name="szStatus">
            ///     0:部門情報含めない、1:部門情報含める</param>
            ///------------------------------------------------------------------------
            public static void csvArrayLoad(string fName, ComboBox tempObj, int szStatus)
            {
                string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory;

                int iX = 0;

                System.Collections.ArrayList al = new System.Collections.ArrayList();

                string[] bArray = null;

                try
                {
                    // 社員名簿CSV読み込み
                    bArray = System.IO.File.ReadAllLines(fName, Encoding.Default);

                    foreach (var t in bArray)
                    {
                        string[] d = t.Split(',');

                        if (d.Length < 5)
                        {
                            continue;
                        }

                        string bn = d[1].PadLeft(5, '0') + "," + d[0] + "";


                        if (szStatus == global.flgOn)
                        {
                            // 組織コード
                            int bCode = Utility.StrtoInt(d[3]);

                            // 組織名称
                            string bName = Utility.NulltoStr(d[2]).Trim();

                            bn += "," + bCode.ToString() + "," + (bName + "");
                        }

                        al.Add(bn);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "CSV社員マスター読み込み", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                finally
                {
                }

                ComboShain cmb1;

                tempObj.Items.Clear();
                tempObj.DisplayMember = "DisplayName";
                tempObj.ValueMember   = "code";

                // 配列をソートします
                al.Sort();

                string alCode = string.Empty;

                foreach (var item in al)
                {
                    string[] d = item.ToString().Split(',');

                    // 重複社員はネグる
                    if (alCode != string.Empty && alCode.Substring(0, 5) == d[0])
                    {
                        continue;
                    }

                    // コンボボックスにセット
                    cmb1             = new ComboShain();
                    cmb1.ID          = 0;
                    cmb1.DisplayName = item.ToString().Replace(',', ' ');

                    string[] cn = item.ToString().Split(',');
                    cmb1.Name = cn[1] + "";
                    cmb1.code = cn[0] + "";

                    if (szStatus == global.flgOn)
                    {
                        cmb1.BumonCode = cn[2] + "";
                        cmb1.BumonName = cn[3] + "";
                    }

                    tempObj.Items.Add(cmb1);

                    alCode = item.ToString();
                }
            }
Example #12
0
            ///------------------------------------------------------------------------
            /// <summary>
            ///     常陽コンピュータサービスエクセル社員マスターコンボボックスロード </summary>
            /// <param name="fName">
            ///     エクセルファイル名</param>
            /// <param name="sheetNum">
            ///     シート名</param>
            /// <param name="tempObj">
            ///     コンボボックス</param>
            /// <param name="szStatus">
            ///     0:部門情報含めない、1:部門情報含める</param>
            ///------------------------------------------------------------------------
            public static void xlsArrayLoad(string fName, string sheetNum, ComboBox tempObj, int szStatus)
            {
                string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory;

                Excel.Application oXls = new Excel.Application();

                Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(fName, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing));

                Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[sheetNum];

                Excel.Range   dRg;
                Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2];

                const int C_BCODE = 7;
                const int C_BNAME = 8;
                const int C_SCODE = 11;
                const int C_SEI   = 24;
                const int C_MEI   = 25;

                int iX = 0;

                System.Collections.ArrayList al = new System.Collections.ArrayList();

                try
                {
                    int frmRow = 21;  // 開始行
                    int toRow  = oxlsSheet.UsedRange.Rows.Count;

                    for (int i = frmRow; i <= toRow; i++)
                    {
                        // 社員番号
                        dRg = (Excel.Range)oxlsSheet.Cells[i, C_SCODE];

                        // 社員番号に有効値があること
                        string sc = dRg.Text.ToString().Trim();
                        if (Utility.StrtoInt(sc) == 0)
                        {
                            continue;
                        }

                        // 社員姓
                        dRg = (Excel.Range)oxlsSheet.Cells[i, C_SEI];
                        string sei = dRg.Text.ToString().Trim();

                        // 社員名
                        dRg = (Excel.Range)oxlsSheet.Cells[i, C_MEI];
                        string mei = dRg.Text.ToString().Trim();

                        string bn = sc.ToString().PadLeft(5, '0') + "," + (sei + " " + mei) + "";

                        if (szStatus == global.flgOn)
                        {
                            // 組織コード
                            dRg = (Excel.Range)oxlsSheet.Cells[i, C_BCODE];
                            int bCode = Utility.StrtoInt(dRg.Text.ToString().Trim());

                            // 組織名称
                            dRg = (Excel.Range)oxlsSheet.Cells[i, C_BNAME];
                            string bName = dRg.Text.ToString().Trim();

                            bn += "," + bCode.ToString() + "," + (bName + "");
                        }

                        al.Add(bn);

                        iX++;
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エクセル社員マスター読み込み", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                finally
                {
                    // ウィンドウを非表示にする
                    oXls.Visible = false;

                    // 保存処理
                    oXls.DisplayAlerts = false;

                    // Bookをクローズ
                    oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing);

                    // Excelを終了
                    oXls.Quit();

                    // COM オブジェクトの参照カウントを解放する
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls);
                    oXls      = null;
                    oXlsBook  = null;
                    oxlsSheet = null;
                    GC.Collect();
                }

                ComboShain cmb1;

                tempObj.Items.Clear();
                tempObj.DisplayMember = "DisplayName";
                tempObj.ValueMember   = "code";

                // 配列をソートします
                al.Sort();

                string alCode = string.Empty;

                foreach (var item in al)
                {
                    string[] d = item.ToString().Split(',');

                    // 重複社員はネグる
                    if (alCode != string.Empty && alCode.Substring(0, 5) == d[0])
                    {
                        continue;
                    }

                    // コンボボックスにセット
                    cmb1             = new ComboShain();
                    cmb1.ID          = 0;
                    cmb1.DisplayName = item.ToString().Replace(',', ' ');

                    string[] cn = item.ToString().Split(',');
                    cmb1.Name = cn[1] + "";
                    cmb1.code = cn[0] + "";

                    if (szStatus == global.flgOn)
                    {
                        cmb1.BumonCode = cn[2] + "";
                        cmb1.BumonName = cn[3] + "";
                    }

                    tempObj.Items.Add(cmb1);

                    alCode = item.ToString();
                }
            }
Example #13
0
            ///----------------------------------------------------------------
            /// <summary>
            ///     CSVデータから社員コンボボックスにロードする </summary>
            /// <param name="tempObj">
            ///     コンボボックスオブジェクト</param>
            /// <param name="fName">
            ///     CSVデータファイルパス</param>
            ///----------------------------------------------------------------
            public static void loadCsv(ComboBox tempObj, string fName)
            {
                string[] bArray = null;

                try
                {
                    ComboShain cmb1;

                    tempObj.Items.Clear();
                    tempObj.DisplayMember = "DisplayName";
                    tempObj.ValueMember   = "code";

                    // 社員名簿CSV読み込み
                    bArray = System.IO.File.ReadAllLines(fName, Encoding.Default);

                    System.Collections.ArrayList al = new System.Collections.ArrayList();

                    foreach (var t in bArray)
                    {
                        string[] d = t.Split(',');

                        if (d.Length < 5)
                        {
                            continue;
                        }

                        string bn = d[1].PadLeft(5, '0') + "," + d[0] + "";
                        al.Add(bn);
                    }

                    // 配列をソートします
                    al.Sort();

                    string alCode = string.Empty;

                    foreach (var item in al)
                    {
                        string[] d = item.ToString().Split(',');

                        // 重複社員はネグる
                        if (alCode != string.Empty && alCode.Substring(0, 5) == d[0])
                        {
                            continue;
                        }

                        // コンボボックスにセット
                        cmb1             = new ComboShain();
                        cmb1.ID          = 0;
                        cmb1.DisplayName = item.ToString().Replace(',', ' ');

                        string[] cn = item.ToString().Split(',');
                        cmb1.Name = cn[1] + "";
                        cmb1.code = cn[0] + "";
                        tempObj.Items.Add(cmb1);

                        alCode = item.ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "社員コンボボックスロード");
                }
            }
Example #14
0
        public static void Init2D(ref double[] q, ref List <Point3d> gpinit, ref List <Curve> tpinit, ref List <Curve> spinit, ref List <int> lpinit, ref List <Vector3d> lvinit)
        {
            int nk = gpinit.Count; //number of nodes
            int nm = tpinit.Count; //number of members

            double[,,] tt = new double[6, 6, nm];

            int[]    istart = new int[nm];
            int[]    iend   = new int[nm];
            double[] dll    = new double[nm];
            for (int i = 0; i < nm; i++)
            {
                istart[i] = Rhino.Collections.Point3dList.ClosestIndexInList(gpinit, tpinit[i].PointAtStart);
                iend[i]   = Rhino.Collections.Point3dList.ClosestIndexInList(gpinit, tpinit[i].PointAtEnd);
                double dx = gpinit[iend[i]].X - gpinit[istart[i]].X;
                double dy = gpinit[iend[i]].Y - gpinit[istart[i]].Y;
                double dz = gpinit[iend[i]].Z - gpinit[istart[i]].Z;
                dll[i]      = Math.Sqrt(dx * dx + dy * dy + dz * dz);
                tt[0, 0, i] = dx / dll[i];
                tt[1, 0, i] = dy / dll[i];
                tt[2, 0, i] = dz / dll[i];
                if (Math.Abs(tt[0, 0, i]) >= 0.9)
                {
                    tt[1, 1, i] = .1e1;
                }
                else
                {
                    tt[0, 1, i] = .1e1;
                }
                tt[0, 2, i] = tt[1, 0, i] * tt[2, 1, i] - tt[2, 0, i] * tt[1, 1, i];
                tt[1, 2, i] = tt[2, 0, i] * tt[0, 1, i] - tt[0, 0, i] * tt[2, 1, i];
                tt[2, 2, i] = tt[0, 0, i] * tt[1, 1, i] - tt[1, 0, i] * tt[0, 1, i];
                double ddd = Math.Sqrt(tt[0, 2, i] * tt[0, 2, i] + tt[1, 2, i] * tt[1, 2, i] + tt[2, 2, i] * tt[2, 2, i]);
                for (int j = 0; j < 3; j++)
                {
                    tt[j, 2, i] /= ddd;
                }
                tt[0, 1, i] = tt[1, 2, i] * tt[2, 0, i] - tt[2, 2, i] * tt[1, 0, i];
                tt[1, 1, i] = tt[2, 2, i] * tt[0, 0, i] - tt[0, 2, i] * tt[2, 0, i];
                tt[2, 1, i] = tt[0, 2, i] * tt[1, 0, i] - tt[1, 2, i] * tt[0, 0, i];
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        tt[j + 3, k + 3, i] = tt[j, k, i];
                    }
                }
            }


            int nsp = spinit.Count;

            ///fix0 is an index of supported & loaded points
            System.Collections.ArrayList fix0 = new System.Collections.ArrayList();
            //add supported points' indices into fix0
            for (int i = 0; i < nk; i++)
            {
                for (int j = 0; j < nsp; j++)
                {
                    double  t       = new double();
                    bool    scparam = spinit[j].ClosestPoint(gpinit[i], out t);
                    Point3d scp     = spinit[j].PointAt(t);
                    if ((gpinit[i] - scp).IsTiny())
                    {
                        fix0.Add(i);
                    }
                }
            }

            fix0.Sort();//maybe unnecessary??
            //convert to integer array "fix1"
            int[] fix1 = (int[])fix0.ToArray(typeof(int));
            //convert to HashSet(HashSet can remove overlapping values and sort automatically and quickly)
            HashSet <int> fix2 = new HashSet <int>(fix1);

            //convert to integer array "fix"
            int[] fix = new int[fix2.Count];
            //int[] fix = new int[fix2.Count];
            fix2.CopyTo(fix, 0);

            int nfix = fix.Length;
            int ifix = 0;

            int[] free  = new int[nk - nfix];
            int   nfree = 0;

            for (int i = 0; i < nk; i++)
            {
                if (ifix != nfix)
                {
                    if (i == fix[ifix])
                    {
                        ifix++;
                    }
                    else
                    {
                        free[nfree] = i;
                        nfree++;
                    }
                }

                else
                {
                    free[nfree] = i;
                    nfree++;
                }
            }

            int ifree = 0;

            int[,] ird = new int[3, nk];

            for (int i = 0; i < nk; i++)
            {
                ird[2, i] = 1;
            }

            for (int i = 0; i < nfix; i++)
            {
                ird[0, fix[i]] = -1;
                ird[1, fix[i]] = -1;
            }

            for (int i = 0; i < nk; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (ird[j, i] == 0)
                    {
                        ird[j, i] = ifree;
                        ifree++;
                    }
                    else
                    {
                        ird[j, i] = nfree * 2;
                    }
                }
            }

            int[,] ir = new int[6, nm];
            for (int i = 0; i < nm; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    ir[j, i]     = ird[j, istart[i]];
                    ir[j + 3, i] = ird[j, iend[i]];
                }
            }

            double[,] tp = new double[nm, nfree * 2];
            for (int j = 0; j < 6; j++)
            {
                for (int i = 0; i < nm; i++)
                {
                    if (ir[j, i] < nfree * 2)
                    {
                        tp[i, ir[j, i]] -= tt[j, 0, i];
                        tp[i, ir[j, i]] += tt[j, 3, i];
                    }
                }
            }
            for (int j = 0; j < nfree * 2; j++)
            {
                for (int i = 0; i < nm; i++)
                {
                    { tp[i, j] /= dll[i]; }
                }
            }

            double[,] dk = new double[6, 6];
            dk[0, 0]     = .1e1;
            dk[0, 3]     = -.1e1;
            dk[3, 0]     = -.1e1;
            dk[3, 3]     = .1e1;

            double[,,] ddk = new double[6, 6, nm];
            for (int ii = 0; ii < nm; ii++)
            {
                double[,] ff1 = new double[6, 6];
                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        for (int k = 0; k < 6; k++)
                        {
                            ff1[i, k] += tt[i, j, ii] * dk[j, k];
                        }
                    }
                }

                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        for (int k = 0; k < 6; k++)
                        {
                            ddk[i, k, ii] += (ff1[i, j] * tt[k, j, ii]);
                        }
                    }
                }
            }

            ///ddk=ddk*E*A/L, E=A=1.0
            for (int i = 0; i < nm; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    for (int k = 0; k < 6; k++)
                    {
                        ddk[j, k, i] /= dll[i];
                    }
                }
            }

            double[,] ak = new double[nfree * 2, nfree * 2];
            for (int j = 0; j < 6; j++)
            {
                for (int k = 0; k < 6; k++)
                {
                    for (int i = 0; i < nm; i++)
                    {
                        if (ir[k, i] < nfree * 2)
                        {
                            if (ir[j, i] < nfree * 2)
                            {
                                ak[ir[j, i], ir[k, i]] += ddk[j, k, i];
                            }
                        }
                    }
                }
            }

            double[] pp = new double[nfree * 2];
            for (int i = 0; i < lpinit.Count; i++)
            {
                pp[ird[0, lpinit[i]]] = lvinit[i].X;
                pp[ird[1, lpinit[i]]] = lvinit[i].Y;
            }

            var ak2 = ln.Matrix <double> .Build.DenseOfArray(ak);

            var pp2 = ln.Vector <double> .Build.DenseOfArray(pp);

            var ws = ln.Vector <double> .Build.Dense(nfree * 2);

            ws = ak2.Inverse() * pp2;

            double[] st = new double[nm];
            for (int i = 0; i < nm; i++)
            {
                for (int j = 0; j < nfree * 2; j++)
                {
                    st[i] += tp[i, j] * ws[j];
                }
            }

            double[] af = new double[nm];
            ///af=st*E*A, E=1.0, A=1.0
            for (int i = 0; i < nm; i++)
            {
                af[i] = st[i] * 1.0 * 1.0;
                q[i]  = af[i] / dll[i];
            }
        }
Example #15
0
        public static void htmlResult(System.Collections.Hashtable raceStat, string datFile, string raceDir, infoRace currInfoRace)
        {
            int firstMaxLap = 0;
            long firstTotalTime = 0;
            int curPos;
            wr.wrInfo wi;

            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            // Do Stat on Leader of race
            System.Collections.ArrayList raceLeader = new System.Collections.ArrayList();
            int CurLap = -1;
            long minLapTime;
            int PLID;
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];
                p.tmpTime = 0;
            }
            // Set Lap By Lap of Leader
            while (true)
            {
                CurLap++;
                minLapTime = 0;
                PLID = -1;
                for (int i = 0; i < sorted.Count; i++)
                {
                    raceStats p = (raceStats)sorted[i];
                    if (p.lap.Count > CurLap)
                    {
                        p.tmpTime = p.tmpTime + (p.lap[CurLap] as Lap).lapTime;
                        if (minLapTime == 0 || p.tmpTime < minLapTime)
                        {
                            PLID = p.PLID;
                            minLapTime = p.tmpTime;
                        }
                    }
                }
                if (PLID == -1)
                    goto fin;
                (raceStat[PLID] as raceStats).lapsLead++;
                raceLeader.Add(PLID);
            }
            fin:
            // CALC avg
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];
                try
                {
                    if( p.lap.Count != 0 )
                        p.avgTime = p.cumuledTime / p.lap.Count;
                }
                catch
                {
                    p.avgTime = 0;
                }
            }
            // CALC lapStability
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];

                if (p.avgTime == 0)
                {
                    p.lapStability = -1;
                    continue;
                }
                for (int j = 0; j < p.lap.Count; j++)
                {
                    p.lapStability += System.Math.Pow((double)(p.avgTime - (p.lap[j] as Lap).lapTime), 2);
                }
                if (p.lap.Count > 1)
                    p.lapStability = System.Math.Sqrt(p.lapStability / ((p.lap.Count) - 1));
                else
                    p.lapStability = -1;
            }

            System.IO.StreamWriter sw = new System.IO.StreamWriter(raceDir + "/" + datFile + "_results_race.html");
            System.IO.StreamReader sr = new System.IO.StreamReader("./templates/html_race.tpl");
            string readLine;
            combinedSplit = 0;

            while (true)
            {
                readLine = sr.ReadLine();
                if (readLine == null)
                    break;

                #region RaceResults
                if (readLine.IndexOf("[RaceResults") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_RESULT;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        curPos++;
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];

                        /*                        string lnickname = lfsColorToHtml( p.nickName ); */
                        string lnickname = lfsColorToHtml(getAllNickName(p));
                        string allUserName = getAllUserName(p);
                        if (i == 0)
                        {
                            firstMaxLap = p.lap.Count;
                            firstTotalTime = p.totalTime;
                        }
                        wreadLine = wreadLine.Replace("[RaceResults ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        p.finalPos = curPos;
                        wreadLine = wreadLine.Replace("{Position}", p.finalPos.ToString());
                        wreadLine = wreadLine.Replace("{PlayerNameColoured}", lnickname);
                        wreadLine = wreadLine.Replace("{UserNameLink}", p.userName);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName );
                        wreadLine = wreadLine.Replace("{Car}", p.CName);
                        wreadLine = wreadLine.Replace("{Plate}", lfsStripColor( p.Plate ));
                        wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                        if( wi == null )
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.bestLap - wi.WRTime));

                        // if Racer do not finish
                        if (p.resultNum == 999)
                            wreadLine = wreadLine.Replace("{Gap}", "DNF");
                        else
                        {
                            if (firstMaxLap == p.lap.Count)
                            {
                                if (i == 0)
                                    wreadLine = wreadLine.Replace("{Gap}", raceStats.LfstimeToString(p.totalTime));
                                else
                                {
                                    long tres;
                                    tres = p.totalTime - firstTotalTime;
                                    wreadLine = wreadLine.Replace("{Gap}", "+" + raceStats.LfstimeToString(tres));
                                }
                            }
                            else
                                wreadLine = wreadLine.Replace("{Gap}", "+" + ((int)(firstMaxLap - p.lap.Count)).ToString() + " laps");
                        }
                        wreadLine = wreadLine.Replace("{BestLap}", raceStats.LfstimeToString(p.bestLap));
                        wreadLine = wreadLine.Replace("{LapsDone}", p.lap.Count.ToString());
                        wreadLine = wreadLine.Replace("{PitsDone}", p.numStop.ToString());
                        wreadLine = wreadLine.Replace("{Flags}", p.sFlags);
                        wreadLine = wreadLine.Replace("{Penalty}", p.penalty);
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region StartOrder

                if (readLine.IndexOf("[StartOrder") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_GRID;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];
                        string lnickname = lfsStripColor(getAllNickName( p ));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[StartOrder ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        p.finalPos = curPos;
                        string gridPos;
                        if (p.gridPos == 999)
                            gridPos = "-";
                        else
                            gridPos = p.gridPos.ToString();
                        wreadLine = wreadLine.Replace("{Position}", gridPos);
                        wreadLine = wreadLine.Replace("{UserNameLink}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region HighestClimber
                if (readLine.IndexOf("[HighestClimber") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_CLIMB;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];
            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[HighestClimber ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        p.finalPos = curPos;
                        if (p.gridPos == 999 || p.resultNum >= 998)
                            continue;
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);
                        wreadLine = wreadLine.Replace("{StartPos}", p.gridPos.ToString());
                        wreadLine = wreadLine.Replace("{FinishPos}", (p.resultNum + 1).ToString());
                        wreadLine = wreadLine.Replace("{Difference}", (p.gridPos - p.resultNum - 1).ToString());

                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region RaceLeader
                if (readLine.IndexOf("[RaceLeader") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_LAPLEAD;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    int oldPLID = -1;
                    int initLap = 0;
                    int endLap = 0;
                    int i;
                    string lnickname;
                    int curPLID = 0;
                    for (i = 0; i < raceLeader.Count; i++)
                    {
                        curPLID = (int)raceLeader[i];
                        if (oldPLID != curPLID)
                        {
                            if (oldPLID != -1)
                            {

                                raceStats p = (raceStats)raceStat[oldPLID];

            //                                lnickname = lfsStripColor(p.nickName);
                                lnickname = lfsStripColor(getAllNickName(p));
                                string allUserName = getAllUserName(p);

                                curPos++;
                                endLap = i;
                                wreadLine = readLine;
                                wreadLine = wreadLine.Replace("[RaceLeader ", "");
                                wreadLine = wreadLine.Replace("]", "");
                                wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
            //                                wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                                wreadLine = wreadLine.Replace("{UserName}", p.userName);
                                wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                                wreadLine = wreadLine.Replace("{UserName}", allUserName);

                                wreadLine = wreadLine.Replace("{LapsLead}", initLap.ToString() + "-" + endLap.ToString());
                                sw.WriteLine(wreadLine);
                            }
                            oldPLID = curPLID;
                            initLap = i + 1;
                        }
                    }
                    if (oldPLID != -1)
                    {
                        raceStats p = (raceStats)raceStat[curPLID];
            //                        lnickname = lfsStripColor(p.nickName);
                        lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        curPos++;
                        endLap = i;
                        wreadLine = readLine;
                        wreadLine = wreadLine.Replace("[RaceLeader ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);
                        wreadLine = wreadLine.Replace("{LapsLead}", initLap.ToString() + "-" + endLap.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region LapsLed

                if (readLine.IndexOf("[LapsLed") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_LAPLEAD;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];
            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[LapsLed ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        p.finalPos = curPos;
                        if (p.lapsLead == 0)
                            continue;
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());
            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{LapsLed}", p.lapsLead.ToString());

                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region relay

                if (readLine.IndexOf("[Relay") == 0)
                {
                    if (currInfoRace.isToc) // if TOC on this race
                    {
                        raceStats.modeSort = (int)sortRaceStats.SORT_RESULT;
                        sorted.Sort();
                        string wreadLine;
                        curPos = 0;
                        for (int i = 0; i < sorted.Count; i++)
                        {
                            wreadLine = readLine;
                            raceStats p = (raceStats)sorted[i];
                            //                        string lnickname = lfsStripColor(p.nickName);
                            string lnickname = lfsStripColor(getAllNickName(p));
                            string allUserName = getAllUserName(p);

                            wreadLine = wreadLine.Replace("[Relay ", "");
                            wreadLine = wreadLine.Replace("]", "");
                            p.finalPos = curPos;
                            //                            if (p.toc.Count == 0)   // No toc for this Racer
                            //                                continue;
                            curPos++;
                            wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                            wreadLine = wreadLine.Replace("{UserName}", allUserName);
                            string allRelays = "";
                            string allLaps = "";
                            string br = "";
                            int last_lap = 1;
                            int nbLaps = 0;
                            for (int j = 0; j < p.toc.Count; j++)
                            {
                                allRelays = allRelays
                                            + br
                                            + lfsStripColor((p.toc[j] as Toc).oldNickName);
                                //                                        + " -> "
                                //                                        + lfsStripColor((p.toc[j] as Toc).newNickName);
                                ;
                                nbLaps = (p.toc[j] as Toc).lap - last_lap + 1;
                                allLaps = allLaps
                                            + br
                                            + (last_lap).ToString() + "-" + (p.toc[j] as Toc).lap + " (" + nbLaps + " " + lang["lg_laps"] + ")";
                                ;
                                last_lap = (p.toc[j] as Toc).lap + 1;
                                br = "<br>";

                            }
                            allRelays = allRelays
                                        + br
                                        + lfsStripColor(p.nickName);
                            if (last_lap <= p.lap.Count)
                            {
                                nbLaps = p.lap.Count - last_lap + 1;
                                allLaps = allLaps
                                            + br
                                            + (last_lap).ToString() + "-" + (p.lap.Count).ToString() + " (" + nbLaps + " " + lang["lg_laps"] + ")";
                                ;
                            }
                            else
                            {
                                nbLaps = 0;
                                allLaps = allLaps
                                            + br
                                            + (p.lap.Count).ToString() + "-" + (p.lap.Count).ToString() + " (" + nbLaps + " " + lang["lg_laps"] + ")";
                                ;
                            }
                            wreadLine = wreadLine.Replace("{Position}", (i + 1).ToString());
                            wreadLine = wreadLine.Replace("{Relays}", allRelays);
                            wreadLine = wreadLine.Replace("{Laps}", allLaps);
                            sw.WriteLine(wreadLine);
                        }

                        continue;
                    }
                    else
                        continue;
                }

                #endregion

                #region FirstLap
                if (readLine.IndexOf("[FirstLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_FIRSTLAP;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.firstTime == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[FirstLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.firstTime;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.firstTime));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.firstTime - baseTime));
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region LapTimesStability
                if (readLine.IndexOf("[LapTimesStability") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_STABILITY;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    double baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.lapStability <= 0  )
                            continue;
            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[LapTimesStability ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.lapStability;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{Deviation}", raceStats.LfstimeToString((long)p.lapStability));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString((long)(p.lapStability - baseTime)));
                        wreadLine = wreadLine.Replace("{LapsDone}", p.lap.Count.ToString());

                        sw.WriteLine(wreadLine);
                    }
                    continue;

                }
            #endregion

                #region AverageLap
                if (readLine.IndexOf("[AverageLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_AVGTIME;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.avgTime == 0)
                            continue;
            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[AverageLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.avgTime;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.avgTime));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.avgTime - baseTime));
                        wreadLine = wreadLine.Replace("{Laps}", p.lap.Count.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region BestLap
                if (readLine.IndexOf("[BestLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BESTLAP;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.bestLap == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[BestLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.bestLap;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.bestLap));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.bestLap - baseTime));
                        wi = wr.getWR( currInfoRace.currentTrackName,p.CName );
                        if (wi == null)
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.bestLap - wi.WRTime));
                        wreadLine = wreadLine.Replace("{Lap}", p.lapBestLap.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
            #endregion

                #region BestSplitTable
                if (readLine.IndexOf("[[BestSplitTable") == 0)
                {
                    System.Collections.ArrayList blockSplit = new System.Collections.ArrayList();
                    blockSplit.Add(readLine);
                    while (true)
                    {
                        readLine = sr.ReadLine();
                        if (readLine == null)
                            break;
                        if (readLine.IndexOf("]]") != -1)
                        {
                            blockSplit.Add(readLine);
                            break;
                        }
                        blockSplit.Add(readLine);
                    }
                    for (int j = 0; j <= currInfoRace.maxSplit; j++)
                    {
                        for (int i = 0; i < sorted.Count; i++)
                        {
                            raceStats p = (raceStats)sorted[i];
                            wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                            if (j == currInfoRace.maxSplit)
                            {
                                p.curBestSplit = p.bestLastSplit;
                                p.curLapBestSplit = p.lapBestLastSplit;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplitLast;
                                continue;
                            }
                            if (j == 0)
                            {
                                p.curBestSplit = p.bestSplit1;
                                p.curLapBestSplit = p.lapBestSplit1;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                            if (j == 1)
                            {
                                p.curBestSplit = p.bestSplit2;
                                p.curLapBestSplit = p.lapBestSplit2;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                            if (j == 2)
                            {
                                p.curBestSplit = p.bestSplit3;
                                p.curLapBestSplit = p.lapBestSplit3;
                                if (wi == null)
                                    p.curWrSplit = 0;
                                else
                                    p.curWrSplit = wi.sectorSplit[j];
                                continue;
                            }
                        }
                        for (int k = 0; k < blockSplit.Count; k++)
                        {
                            readLine = (string)blockSplit[k];
                            if (readLine.IndexOf("[BestSplit") == 0)
                            {
                                raceStats.modeSort = (int)sortRaceStats.SORT_BESTSPLIT;
                                sorted.Sort();
                                string wreadLine;
                                curPos = 0;
                                long baseTime = 0;
                                for (int i = 0; i < sorted.Count; i++)
                                {
                                    raceStats p = (raceStats)sorted[i];

                                    wreadLine = readLine;
                                    if (p.curBestSplit == 0)
                                        continue;
            //                                    string lnickname = lfsStripColor(p.nickName);
                                    string lnickname = lfsStripColor(getAllNickName(p));
                                    string allUserName = getAllUserName(p);

                                    wreadLine = wreadLine.Replace("[BestSplit ", "");
                                    wreadLine = wreadLine.Replace("]", "");
                                    curPos++;
                                    if (curPos == 1)
                                        baseTime = p.curBestSplit;
                                    wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                                    wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                                    wreadLine = wreadLine.Replace("{UserName}", p.userName);
                                    wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                                    wreadLine = wreadLine.Replace("{UserName}", allUserName);

                                    wreadLine = wreadLine.Replace("{SplitTime}", raceStats.LfstimeToString(p.curBestSplit));
                                    wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString(p.curBestSplit - baseTime));
                                    if( p.curWrSplit == 0 )
                                        wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                                    else
                                        wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString(p.curBestSplit - p.curWrSplit));
                                    wreadLine = wreadLine.Replace("{Lap}", p.curLapBestSplit.ToString());
                                    sw.WriteLine(wreadLine);
                                }
                                combinedSplit = combinedSplit + baseTime;
                                continue;
                            }
                            readLine = updateGlob(readLine,  datFile, currInfoRace, "race");
                            readLine = readLine.Replace("]]", "");
                            readLine = readLine.Replace("[[BestSplitTable ", "");
                            readLine = readLine.Replace("{SplitNumber}", (j + 1).ToString());
                            sw.WriteLine(readLine);
                        }
                    }
                }
            #endregion

                #region BestPossibleLap
                if (readLine.IndexOf("[BestPossibleLap") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_TPB;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    long baseTime = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if ((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[BestPossibleLap ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseTime = p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{LapTime}", raceStats.LfstimeToString(p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfstimeToString((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) - baseTime));
                        wreadLine = wreadLine.Replace("{DifferenceToBestLap}", raceStats.LfstimeToString((p.bestLap - p.bestSplit1 - p.bestSplit2 - p.bestSplit3 - p.bestLastSplit)));
                        wi = wr.getWR(currInfoRace.currentTrackName, p.CName);
                        if (wi == null)
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", "");
                        else
                            wreadLine = wreadLine.Replace("{DifferenceToWR}", raceStats.LfstimeToString((p.bestSplit1 + p.bestSplit2 + p.bestSplit3 + p.bestLastSplit) - wi.WRTime));
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                #region BlueFlagCausers
                if (readLine.IndexOf("[BlueFlagCausers") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BLUEFLAG;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.blueFlags == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[BlueFlagCausers ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{BlueFlagsCount}", p.blueFlags.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                #region YellowFlagCausers
                if (readLine.IndexOf("[YellowFlagCausers") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_YELLOWFLAG;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.yellowFlags == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[YellowFlagCausers ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{YellowFlagsCount}", p.yellowFlags.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                #region PitStops
                if (readLine.IndexOf("[PitStops") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_PIT;
                    sorted.Sort();
                    string wreadLine;
                    string pitinfo = "";
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[PitStops ", "");
                        wreadLine = wreadLine.Replace("]", "");
            // If no Pit not vue pit stop
                        if (p.pit.Count == 0)
                            continue;
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        pitinfo = "";
                        string br = "";
                        string virg = "";
                        string SWork="";
                        for( int j = 0; j < p.pit.Count;j++ ){
                            SWork = "{lg_lap} " + ((p.pit[j] as Pit).LapsDone + 1) + ":";
                            long Work = (p.pit[j] as Pit).Work;

                            if ((Work & (long)InSim.PIT_work.PSE_STOP) != 0)
                            {
                                SWork = SWork + virg + " {lg_stop}";
                                virg = ", ";
                            }
                            if ((Work & (long)InSim.PIT_work.PSE_SETUP) != 0)
                            {
                                SWork = SWork + virg + "{lg_dam_set}";
                                virg = ", ";
                            }
                            if (
                                (Work & (long)InSim.PIT_work.PSE_FR_DAM) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RE_DAM) != 0
                                || (Work & (long)InSim.PIT_work.PSE_LE_FR_DAM) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RI_FR_DAM) != 0
                                || (Work & (long)InSim.PIT_work.PSE_LE_RE_DAM) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RI_RE_DAM) != 0
                                )
                            {
                                SWork = SWork + virg + "{lg_dam_mec}";
                                virg = ", ";
                            }
                            if (
                                (Work & (long)InSim.PIT_work.PSE_BODY_MINOR) != 0
                                || (Work & (long)InSim.PIT_work.PSE_BODY_MAJOR) != 0
                                )
                            {
                                SWork = SWork + virg + "{lg_dam_body}";
                                virg = ", ";
                            }
                            if (
                                (Work & (long)InSim.PIT_work.PSE_FR_WHL) != 0
                                || (Work & (long)InSim.PIT_work.PSE_LE_FR_WHL) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RI_FR_WHL) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RE_WHL) != 0
                                || (Work & (long)InSim.PIT_work.PSE_LE_RE_WHL) != 0
                                || (Work & (long)InSim.PIT_work.PSE_RI_RE_WHL) != 0
                                )
                            {
                                SWork = SWork + virg + "{lg_dam_whe}";
                                virg = ", ";
                            }
                            if ((Work & (long)InSim.PIT_work.PSE_REFUEL) != 0)
                            {
                                SWork = SWork + virg + " {lg_refuel}";
                                virg = ", ";
                            }
                            if( (p.pit[j] as Pit).STime != 0 )
                                SWork = SWork + virg + "{lg_startpit}";
                            SWork = updateGlob(SWork, datFile, currInfoRace, "race");
                            pitinfo = pitinfo + br + SWork + " (" + raceStats.LfstimeToString((p.pit[j] as Pit).STime) + ")";
                            br = "<BR>";
                        }
                        wreadLine = wreadLine.Replace("{PitInfo}", pitinfo);
                        wreadLine = wreadLine.Replace("{PitTime}", raceStats.LfstimeToString(p.cumuledStime));
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                #region Penalties
                if (readLine.IndexOf("[Penalties") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_PEN;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.numPen == 0)
                            continue;
                        string penaltyInfo = "";
                        for (int j = 0; j < p.pen.Count; j++)
                        {
                            string strPen = "";
                            if ((p.pen[j] as Penalty).NewPen != (int)InSim.pen.PENALTY_NONE)
                                strPen = Enum.GetName(typeof(InSim.pen), (p.pen[j] as Penalty).NewPen);
                            else
                                strPen = Enum.GetName(typeof(InSim.pen), (p.pen[j] as Penalty).OldPen);
                            strPen = "{lg_" + strPen.Remove(0, 8) + "}";
                            penaltyInfo += "{lg_lap} " + (p.pen[j] as Penalty).Lap.ToString() + ": " + strPen.ToLower();
                            penaltyInfo += "<BR>";

                        }

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[Penalties ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{PenaltyInfo}", penaltyInfo);
                        wreadLine = wreadLine.Replace("{PenaltyCount}", p.numPen.ToString());
                        wreadLine = updateGlob(wreadLine, datFile, currInfoRace, "race");
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                #region TopSpeed
                if (readLine.IndexOf("[TopSpeed") == 0)
                {
                    raceStats.modeSort = (int)sortRaceStats.SORT_BESTSPEED;
                    sorted.Sort();
                    string wreadLine;
                    curPos = 0;
                    int baseSpeed = 0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        raceStats p = (raceStats)sorted[i];

                        wreadLine = readLine;
                        if (p.bestSpeed == 0)
                            continue;

            //                        string lnickname = lfsStripColor(p.nickName);
                        string lnickname = lfsStripColor(getAllNickName(p));
                        string allUserName = getAllUserName(p);

                        wreadLine = wreadLine.Replace("[TopSpeed ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        curPos++;
                        if (curPos == 1)
                            baseSpeed = p.bestSpeed;
                        wreadLine = wreadLine.Replace("{Position}", curPos.ToString());

            //                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
            //                        wreadLine = wreadLine.Replace("{UserName}", p.userName);
                        wreadLine = wreadLine.Replace("{PlayerName}", lnickname);
                        wreadLine = wreadLine.Replace("{UserName}", allUserName);

                        wreadLine = wreadLine.Replace("{TopSpeed}", raceStats.LfsSpeedToString(p.bestSpeed));
                        wreadLine = wreadLine.Replace("{Difference}", raceStats.LfsSpeedToString(baseSpeed - p.bestSpeed));
                        wreadLine = wreadLine.Replace("{TopSpeedLap}", p.lapBestSpeed.ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                #endregion

                readLine = updateGlob(readLine, datFile, currInfoRace, "race");
                sw.WriteLine(readLine);
            }
            sw.Close();
            sr.Close();
        }
Example #16
0
            /// <summary>
            /// Obtain the minimum element of the given collection with the specified comparator.
            /// </summary>
            /// <param name="Collection">Collection from which the minimum value will be obtained.</param>
            /// <param name="Comparator">The comparator with which to determine the minimum element.</param>
            /// <returns></returns>
            public static System.Object Min(System.Collections.ICollection Collection, System.Collections.IComparer Comparator)
            {
                System.Collections.ArrayList tempArrayList;

                if (((System.Collections.ArrayList)Collection).IsReadOnly)
                    throw new System.NotSupportedException();

                if ((Comparator == null) || (Comparator is System.Collections.Comparer))
                {
                    try
                    {
                        tempArrayList = new System.Collections.ArrayList(Collection);
                        tempArrayList.Sort();
                    }
                    catch (System.InvalidOperationException e)
                    {
                        throw new System.InvalidCastException(e.Message);
                    }
                    return (System.Object)tempArrayList[0];
                }
                else
                {
                    try
                    {
                        tempArrayList = new System.Collections.ArrayList(Collection);
                        tempArrayList.Sort(Comparator);
                    }
                    catch (System.InvalidOperationException e)
                    {
                        throw new System.InvalidCastException(e.Message);
                    }
                    return (System.Object)tempArrayList[0];
                }
            }
Example #17
0
 public override void Sort(System.Collections.ArrayList list)
 {
     list.Sort(); //Default is Quicksort
     Console.WriteLine("QuickSorted List");
 }
Example #18
0
		/// <summary> Tests that a query matches the an expected set of documents using Hits.
		/// 
		/// <p>
		/// Note that when using the Hits API, documents will only be returned
		/// if they have a positive normalized score.
		/// </p>
		/// </summary>
		/// <param name="query">the query to test
		/// </param>
		/// <param name="searcher">the searcher to test the query against
		/// </param>
		/// <param name="defaultFieldName">used for displaing the query in assertion messages
		/// </param>
		/// <param name="results">a list of documentIds that must match the query
		/// </param>
		/// <seealso cref="Searcher.Search(Query)">
		/// </seealso>
		/// <seealso cref="CheckHitCollector">
		/// </seealso>
		public static void  CheckHits_Renamed(Query query, System.String defaultFieldName, Searcher searcher, int[] results)
		{
			if (searcher is IndexSearcher)
			{
				QueryUtils.Check(query, (IndexSearcher) searcher);
			}
			
			Hits hits = searcher.Search(query);
			
			System.Collections.ArrayList correct = new System.Collections.ArrayList(results.Length);
			for (int i = 0; i < results.Length; i++)
			{
				correct.Add(results[i]);
			}

			System.Collections.ArrayList actual = new System.Collections.ArrayList(hits.Length());
			for (int i = 0; i < hits.Length(); i++)
			{
				actual.Add(hits.Id(i));
			}
			
			Assert.AreEqual(correct.Count, actual.Count);
			correct.Sort();
			actual.Sort();
			for (int i = 0; i < correct.Count; i++)
			{
				Assert.AreEqual(correct[i], actual[i]);
			}
			
			QueryUtils.Check(query, searcher);
		}
Example #19
0
 public override void Sort(System.Collections.ArrayList list)
 {
     list.Sort(); //no-implement
     Console.WriteLine("ShellSorted List");
 }
Example #20
0
        /// <summary> Write a Class XML Element from attributes in a type. </summary>
        public virtual void WriteClass(System.Xml.XmlWriter writer, System.Type type)
        {
            object[] attributes = type.GetCustomAttributes(typeof(ClassAttribute), false);
            if(attributes.Length == 0)
                return;
            ClassAttribute attribute = attributes[0] as ClassAttribute;

            writer.WriteStartElement( "class" );
            // Attribute: <entity-name>
            if(attribute.EntityName != null)
            writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, type));
            // Attribute: <name>
            if(attribute.Name != null)
            writer.WriteAttributeString("name", GetAttributeValue(attribute.Name, type));
            // Attribute: <proxy>
            if(attribute.Proxy != null)
            writer.WriteAttributeString("proxy", GetAttributeValue(attribute.Proxy, type));
            // Attribute: <lazy>
            if( attribute.LazySpecified )
            writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false");
            // Attribute: <schema-action>
            if(attribute.SchemaAction != null)
            writer.WriteAttributeString("schema-action", GetAttributeValue(attribute.SchemaAction, type));
            // Attribute: <table>
            if(attribute.Table != null)
            writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, type));
            // Attribute: <schema>
            if(attribute.Schema != null)
            writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, type));
            // Attribute: <catalog>
            if(attribute.Catalog != null)
            writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, type));
            // Attribute: <subselect>
            if(attribute.Subselect != null)
            writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, type));
            // Attribute: <discriminator-value>
            if(attribute.DiscriminatorValue != null)
            writer.WriteAttributeString("discriminator-value", GetAttributeValue(attribute.DiscriminatorValue, type));
            // Attribute: <mutable>
            if( attribute.MutableSpecified )
            writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false");
            // Attribute: <abstract>
            if( attribute.AbstractSpecified )
            writer.WriteAttributeString("abstract", attribute.Abstract ? "true" : "false");
            // Attribute: <polymorphism>
            if(attribute.Polymorphism != PolymorphismType.Unspecified)
            writer.WriteAttributeString("polymorphism", GetXmlEnumValue(typeof(PolymorphismType), attribute.Polymorphism));
            // Attribute: <where>
            if(attribute.Where != null)
            writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, type));
            // Attribute: <persister>
            if(attribute.Persister != null)
            writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, type));
            // Attribute: <dynamic-update>
            if( attribute.DynamicUpdateSpecified )
            writer.WriteAttributeString("dynamic-update", attribute.DynamicUpdate ? "true" : "false");
            // Attribute: <dynamic-insert>
            if( attribute.DynamicInsertSpecified )
            writer.WriteAttributeString("dynamic-insert", attribute.DynamicInsert ? "true" : "false");
            // Attribute: <batch-size>
            if(attribute.BatchSize != -9223372036854775808)
            writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString());
            // Attribute: <select-before-update>
            if( attribute.SelectBeforeUpdateSpecified )
            writer.WriteAttributeString("select-before-update", attribute.SelectBeforeUpdate ? "true" : "false");
            // Attribute: <optimistic-lock>
            if(attribute.OptimisticLock != OptimisticLockMode.Unspecified)
            writer.WriteAttributeString("optimistic-lock", GetXmlEnumValue(typeof(OptimisticLockMode), attribute.OptimisticLock));
            // Attribute: <check>
            if(attribute.Check != null)
            writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, type));
            // Attribute: <rowid>
            if(attribute.RowId != null)
            writer.WriteAttributeString("rowid", GetAttributeValue(attribute.RowId, type));
            // Attribute: <node>
            if(attribute.Node != null)
            writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, type));

            WriteUserDefinedContent(writer, type, null, attribute);
            // Element: <meta>
            System.Collections.ArrayList MetaList = FindAttributedMembers( attribute, typeof(MetaAttribute), type );
            foreach( System.Reflection.MemberInfo member in MetaList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MetaAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MetaAttribute), attribute);
            // Element: <subselect>
            System.Collections.ArrayList SubselectList = FindAttributedMembers( attribute, typeof(SubselectAttribute), type );
            foreach( System.Reflection.MemberInfo member in SubselectList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SubselectAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SubselectAttribute), attribute);
            // Element: <cache>
            System.Collections.ArrayList CacheList = FindAttributedMembers( attribute, typeof(CacheAttribute), type );
            foreach( System.Reflection.MemberInfo member in CacheList )
            {
                object[] objects = member.GetCustomAttributes(typeof(CacheAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteCache(writer, member, memberAttrib as CacheAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(CacheAttribute), attribute);
            // Element: <synchronize>
            System.Collections.ArrayList SynchronizeList = FindAttributedMembers( attribute, typeof(SynchronizeAttribute), type );
            foreach( System.Reflection.MemberInfo member in SynchronizeList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SynchronizeAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SynchronizeAttribute), attribute);
            // Element: <comment>
            System.Collections.ArrayList CommentList = FindAttributedMembers( attribute, typeof(CommentAttribute), type );
            foreach( System.Reflection.MemberInfo member in CommentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(CommentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(CommentAttribute), attribute);
            // Element: <tuplizer>
            System.Collections.ArrayList TuplizerList = FindAttributedMembers( attribute, typeof(TuplizerAttribute), type );
            foreach( System.Reflection.MemberInfo member in TuplizerList )
            {
                object[] objects = member.GetCustomAttributes(typeof(TuplizerAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteTuplizer(writer, member, memberAttrib as TuplizerAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(TuplizerAttribute), attribute);
            // Element: <id>
            System.Collections.ArrayList IdList = FindAttributedMembers( attribute, typeof(IdAttribute), type );
            foreach( System.Reflection.MemberInfo member in IdList )
            {
                object[] objects = member.GetCustomAttributes(typeof(IdAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteId(writer, member, memberAttrib as IdAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(IdAttribute), attribute);
            // Element: <composite-id>
            System.Collections.ArrayList CompositeIdList = FindAttributedMembers( attribute, typeof(CompositeIdAttribute), type );
            foreach( System.Reflection.MemberInfo member in CompositeIdList )
            {
                object[] objects = member.GetCustomAttributes(typeof(CompositeIdAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteCompositeId(writer, member, memberAttrib as CompositeIdAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(CompositeIdAttribute), attribute);
            // Element: <discriminator>
            System.Collections.ArrayList DiscriminatorList = FindAttributedMembers( attribute, typeof(DiscriminatorAttribute), type );
            foreach( System.Reflection.MemberInfo member in DiscriminatorList )
            {
                object[] objects = member.GetCustomAttributes(typeof(DiscriminatorAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteDiscriminator(writer, member, memberAttrib as DiscriminatorAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(DiscriminatorAttribute), attribute);
            // Element: <natural-id>
            System.Collections.ArrayList NaturalIdList = FindAttributedMembers( attribute, typeof(NaturalIdAttribute), type );
            foreach( System.Reflection.MemberInfo member in NaturalIdList )
            {
                object[] objects = member.GetCustomAttributes(typeof(NaturalIdAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteNaturalId(writer, member, memberAttrib as NaturalIdAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(NaturalIdAttribute), attribute);
            // Element: <version>
            System.Collections.ArrayList VersionList = FindAttributedMembers( attribute, typeof(VersionAttribute), type );
            foreach( System.Reflection.MemberInfo member in VersionList )
            {
                object[] objects = member.GetCustomAttributes(typeof(VersionAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteVersion(writer, member, memberAttrib as VersionAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(VersionAttribute), attribute);
            // Element: <timestamp>
            System.Collections.ArrayList TimestampList = FindAttributedMembers( attribute, typeof(TimestampAttribute), type );
            foreach( System.Reflection.MemberInfo member in TimestampList )
            {
                object[] objects = member.GetCustomAttributes(typeof(TimestampAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteTimestamp(writer, member, memberAttrib as TimestampAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(TimestampAttribute), attribute);
            // Element: <property>
            System.Collections.ArrayList PropertyList = FindAttributedMembers( attribute, typeof(PropertyAttribute), type );
            foreach( System.Reflection.MemberInfo member in PropertyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PropertyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PropertyAttribute), attribute);
            // Element: <many-to-one>
            System.Collections.ArrayList ManyToOneList = FindAttributedMembers( attribute, typeof(ManyToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in ManyToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ManyToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ManyToOneAttribute), attribute);
            // Element: <one-to-one>
            System.Collections.ArrayList OneToOneList = FindAttributedMembers( attribute, typeof(OneToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in OneToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(OneToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteOneToOne(writer, member, memberAttrib as OneToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(OneToOneAttribute), attribute);
            // Element: <component>
            WriteNestedComponentTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(ComponentAttribute), attribute);
            // Element: <dynamic-component>
            System.Collections.ArrayList DynamicComponentList = FindAttributedMembers( attribute, typeof(DynamicComponentAttribute), type );
            foreach( System.Reflection.MemberInfo member in DynamicComponentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(DynamicComponentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                WriteDynamicComponent(writer, member, memberAttribs[0] as DynamicComponentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(DynamicComponentAttribute), attribute);
            // Element: <properties>
            System.Collections.ArrayList PropertiesList = FindAttributedMembers( attribute, typeof(PropertiesAttribute), type );
            foreach( System.Reflection.MemberInfo member in PropertiesList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PropertiesAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteProperties(writer, member, memberAttrib as PropertiesAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PropertiesAttribute), attribute);
            // Element: <any>
            System.Collections.ArrayList AnyList = FindAttributedMembers( attribute, typeof(AnyAttribute), type );
            foreach( System.Reflection.MemberInfo member in AnyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(AnyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(AnyAttribute), attribute);
            // Element: <map>
            System.Collections.ArrayList MapList = FindAttributedMembers( attribute, typeof(MapAttribute), type );
            foreach( System.Reflection.MemberInfo member in MapList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MapAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMap(writer, member, memberAttrib as MapAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MapAttribute), attribute);
            // Element: <set>
            System.Collections.ArrayList SetList = FindAttributedMembers( attribute, typeof(SetAttribute), type );
            foreach( System.Reflection.MemberInfo member in SetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSet(writer, member, memberAttrib as SetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SetAttribute), attribute);
            // Element: <list>
            System.Collections.ArrayList ListList = FindAttributedMembers( attribute, typeof(ListAttribute), type );
            foreach( System.Reflection.MemberInfo member in ListList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ListAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteList(writer, member, memberAttrib as ListAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ListAttribute), attribute);
            // Element: <bag>
            System.Collections.ArrayList BagList = FindAttributedMembers( attribute, typeof(BagAttribute), type );
            foreach( System.Reflection.MemberInfo member in BagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(BagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteBag(writer, member, memberAttrib as BagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(BagAttribute), attribute);
            // Element: <idbag>
            System.Collections.ArrayList IdBagList = FindAttributedMembers( attribute, typeof(IdBagAttribute), type );
            foreach( System.Reflection.MemberInfo member in IdBagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(IdBagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteIdBag(writer, member, memberAttrib as IdBagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(IdBagAttribute), attribute);
            // Element: <array>
            System.Collections.ArrayList ArrayList = FindAttributedMembers( attribute, typeof(ArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in ArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteArray(writer, member, memberAttrib as ArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ArrayAttribute), attribute);
            // Element: <primitive-array>
            System.Collections.ArrayList PrimitiveArrayList = FindAttributedMembers( attribute, typeof(PrimitiveArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in PrimitiveArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PrimitiveArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WritePrimitiveArray(writer, member, memberAttrib as PrimitiveArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PrimitiveArrayAttribute), attribute);
            // Element: <join>
            System.Collections.ArrayList JoinList = FindAttributedMembers( attribute, typeof(JoinAttribute), type );
            foreach( System.Reflection.MemberInfo member in JoinList )
            {
                object[] objects = member.GetCustomAttributes(typeof(JoinAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteJoin(writer, member, memberAttrib as JoinAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(JoinAttribute), attribute);
            // Element: <subclass>
            WriteNestedSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(SubclassAttribute), attribute);
            // Element: <joined-subclass>
            WriteNestedJoinedSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(JoinedSubclassAttribute), attribute);
            // Element: <union-subclass>
            WriteNestedUnionSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(UnionSubclassAttribute), attribute);
            // Element: <loader>
            System.Collections.ArrayList LoaderList = FindAttributedMembers( attribute, typeof(LoaderAttribute), type );
            foreach( System.Reflection.MemberInfo member in LoaderList )
            {
                object[] objects = member.GetCustomAttributes(typeof(LoaderAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(LoaderAttribute), attribute);
            // Element: <sql-insert>
            System.Collections.ArrayList SqlInsertList = FindAttributedMembers( attribute, typeof(SqlInsertAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlInsertList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlInsertAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlInsertAttribute), attribute);
            // Element: <sql-update>
            System.Collections.ArrayList SqlUpdateList = FindAttributedMembers( attribute, typeof(SqlUpdateAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlUpdateList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlUpdateAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlUpdateAttribute), attribute);
            // Element: <sql-delete>
            System.Collections.ArrayList SqlDeleteList = FindAttributedMembers( attribute, typeof(SqlDeleteAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlDeleteList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlDeleteAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlDeleteAttribute), attribute);
            // Element: <filter>
            System.Collections.ArrayList FilterList = FindAttributedMembers( attribute, typeof(FilterAttribute), type );
            foreach( System.Reflection.MemberInfo member in FilterList )
            {
                object[] objects = member.GetCustomAttributes(typeof(FilterAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteFilter(writer, member, memberAttrib as FilterAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(FilterAttribute), attribute);
            // Element: <resultset>
            System.Collections.ArrayList ResultSetList = FindAttributedMembers( attribute, typeof(ResultSetAttribute), type );
            foreach( System.Reflection.MemberInfo member in ResultSetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ResultSetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteResultSet(writer, member, memberAttrib as ResultSetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ResultSetAttribute), attribute);
            // Element: <query>
            System.Collections.ArrayList QueryList = FindAttributedMembers( attribute, typeof(QueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in QueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(QueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteQuery(writer, member, memberAttrib as QueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(QueryAttribute), attribute);
            // Element: <sql-query>
            System.Collections.ArrayList SqlQueryList = FindAttributedMembers( attribute, typeof(SqlQueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlQueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlQueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlQuery(writer, member, memberAttrib as SqlQueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlQueryAttribute), attribute);

            writer.WriteEndElement();
        }
Example #21
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: ListScanV5 <ip> <listfile>");
                Console.WriteLine("Each command must begin with a number, and commands are executed in increasing order.");
                Console.WriteLine("Executed commands are rewritten to the file with a negative number.");
                Console.WriteLine("<taskid> " + CmdLoadSetup.Explain);
                Console.WriteLine("<taskid> " + CmdLoadPlate.Explain);
                Console.WriteLine("<taskid> " + CmdScan.Explain);
                Console.WriteLine("<taskid> " + CmdRun.Explain);
                Console.WriteLine("<taskid> " + CmdBatch.Explain);
                return;
            }
            ScanSrv = (SySal.DAQSystem.ScanServer)System.Runtime.Remoting.RemotingServices.Connect(typeof(SySal.DAQSystem.ScanServer), "tcp://" + args[0] + ":" + ((int)SySal.DAQSystem.OperaPort.ScanServer) + "/ScanServer.rem");
            string[] lines = System.IO.File.ReadAllText(args[1]).Split('\n', '\r');
            System.Collections.ArrayList cmd = new System.Collections.ArrayList();
            int errors = 0;

            foreach (string line in lines)
            {
                if (line.Trim().Length > 0)
                {
                    System.Text.RegularExpressions.Match m = rx_linenum.Match(line);
                    if (m.Success == false)
                    {
                        errors++;
                        Console.WriteLine("Cannot understand line \"" + line + "\"");
                    }
                    else
                    {
                        try
                        {
                            int linenum = Convert.ToInt32(m.Groups[1].Value);
                            switch (m.Groups[2].Value)
                            {
                            case StrLoadSetup: cmd.Add(new CmdLoadSetup(linenum, line, m.Index + m.Length)); break;

                            case StrLoadPlate: cmd.Add(new CmdLoadPlate(linenum, line, m.Index + m.Length)); break;

                            case StrScan: cmd.Add(new CmdScan(linenum, line, m.Index + m.Length)); break;

                            case StrRun: cmd.Add(new CmdRun(linenum, line, m.Index + m.Length)); break;

                            case StrBatch: cmd.Add(new CmdBatch(linenum, line, m.Index + m.Length)); break;

                            default: Console.WriteLine("Unknown command \"" + m.Groups[2].Value + "\"."); errors++; break;
                            }
                        }
                        catch (Exception x)
                        {
                            Console.WriteLine("Error in line \"" + line + "\": " + x.ToString());
                            errors++;
                        }
                    }
                }
            }
            if (errors > 0)
            {
                Console.Error.WriteLine(errors + " error(s) found; aborting.");
                return;
            }
            Console.WriteLine(cmd.Count + " Commands read.");
            int cmdexec = 0;

            do
            {
                cmd.Sort();
                string rewfile = "";
                foreach (Command c in cmd)
                {
                    rewfile += "\r\n" + c.LineNumber + " " + c.ToString();
                }
                try
                {
                    System.IO.File.WriteAllText(args[1], rewfile);
                }
                catch (Exception x)
                {
                    Console.Error.WriteLine("Cannot update list file!\r\nAborting\r\n" + x.ToString());
                    return;
                }
                int ln;
                for (cmdexec = 0; cmdexec < cmd.Count; cmdexec++)
                {
                    if ((ln = (cmd[cmdexec] as Command).LineNumber) > 0)
                    {
                        (cmd[cmdexec] as Command).Execute();
                        (cmd[cmdexec] as Command).LineNumber = -ln;
                        break;
                    }
                }
            }while (cmdexec != cmd.Count);
        }
Example #22
0
		/// <summary>
		/// Output each sfm and the sfm that followed it with the number of occurances in the input file.
		/// Each sfm should be listed, except for the case where the last sfm in the file is only used once.
		/// </summary>
		/// <param name="sfmSorted"></param>
		/// <param name="w"></param>
		/// <param name="reader"></param>
		static void OutputFollowedByInfo(System.Collections.ArrayList sfmSorted, BinaryWriter w, Sfm2Xml.SfmFileReaderEx reader)
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendFormat("{0}{1}{2}{3}{4}", nl, "SFM Followed by Info:", nl, "--------------------------------------", nl);
			sb.AppendFormat("{0}({1}){2}", reader.FileName, reader.Count, nl);
			w.Write(MakeBytes(sb.ToString()));

			byte[] a = new byte[] { (byte)' ', (byte)'-', (byte)' ' };
			byte[] b = new byte[] { (byte)'\t', (byte)'=', (byte)' ' };

			Dictionary<string, Dictionary<string, int>> fbInfo = reader.GetFollowedByInfo();
			foreach (string sfm in sfmSorted)
			{
				if (fbInfo.ContainsKey(sfm) == false)	// case where sfm is only used once and is last marker
					continue;

				Dictionary<string, int> kvp = fbInfo[sfm];
				System.Collections.ArrayList sfm2 = new System.Collections.ArrayList(kvp.Keys);
				sfm2.Sort();

				foreach (string sfmNext in sfm2)
				{
					w.Write(MakeBytes(sfm));
					w.Write(a);
					w.Write(MakeBytes(sfmNext));
					w.Write(b);
					w.Write(MakeBytes((kvp[sfmNext]).ToString("N0")));
					w.Write(m_NL);
				}
			}
		}
Example #23
0
        public virtual OutputQueueData getOutputdata()
        {
            System.Collections.ArrayList ary = new System.Collections.ArrayList();

            //int maxPriority = -1000, maxRuleid = -1000;

            //if (outputQueue.Count == 0)
            //    return null;
            //else
            //{

            //    System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
            //    while (ie.MoveNext())
            //    {
            //        OutputQueueData data = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;
            //        if (data.priority > maxPriority)
            //        {
            //            maxPriority = data.priority;
            //            maxRuleid = data.ruleid;
            //        }
            //    }
            //}
            //return (OutputQueueData)outputQueue[maxRuleid];

            if (outputQueue.Count == 0)
                return null;
            else
            {

                System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
                while (ie.MoveNext())
                {
                    OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                    ary.Add(quedata);
                    //if (data.priority > maxPriority)
                    //{
                    //  //  mergeGerericDisplayData
                    //    maxPriority = data.priority;
                    //    maxRuleid = data.ruleid;
                    //}
                }
            }

            ary.Sort();
            object[] data = ary.ToArray();
            //if (this.deviceName == "CMS-T78-W-41.6")
            //    Console.WriteLine("stop here");

                return (OutputQueueData)data[data.Length-1];
        }
		/// <summary>Creates a segment from all Postings in the Postings
		/// hashes across all ThreadStates & FieldDatas. 
		/// </summary>
		private System.Collections.IList WriteSegment()
		{
			
			System.Diagnostics.Debug.Assert(AllThreadsIdle());
			
			System.Diagnostics.Debug.Assert(nextDocID == numDocsInRAM);
			
			System.String segmentName;
			
			segmentName = segment;
			
			TermInfosWriter termsOut = new TermInfosWriter(directory, segmentName, fieldInfos, writer.GetTermIndexInterval());
			
			IndexOutput freqOut = directory.CreateOutput(segmentName + ".frq");
			IndexOutput proxOut = directory.CreateOutput(segmentName + ".prx");
			
			// Gather all FieldData's that have postings, across all
			// ThreadStates
			System.Collections.ArrayList allFields = new System.Collections.ArrayList();
			System.Diagnostics.Debug.Assert(AllThreadsIdle());
			for (int i = 0; i < threadStates.Length; i++)
			{
				ThreadState state = threadStates[i];
				state.TrimFields();
				int numFields = state.numAllFieldData;
				for (int j = 0; j < numFields; j++)
				{
					ThreadState.FieldData fp = state.allFieldDataArray[j];
					if (fp.numPostings > 0)
						allFields.Add(fp);
				}
			}
			
			// Sort by field name
			allFields.Sort();
			int numAllFields = allFields.Count;
			
			skipListWriter = new DefaultSkipListWriter(termsOut.skipInterval, termsOut.maxSkipLevels, numDocsInRAM, freqOut, proxOut);
			
			int start = 0;
			while (start < numAllFields)
			{
				
				System.String fieldName = ((ThreadState.FieldData) allFields[start]).fieldInfo.name;
				
				int end = start + 1;
				while (end < numAllFields && ((ThreadState.FieldData) allFields[end]).fieldInfo.name.Equals(fieldName))
					end++;
				
				ThreadState.FieldData[] fields = new ThreadState.FieldData[end - start];
				for (int i = start; i < end; i++)
					fields[i - start] = (ThreadState.FieldData) allFields[i];
				
				// If this field has postings then add them to the
				// segment
				AppendPostings(fields, termsOut, freqOut, proxOut);
				
				for (int i = 0; i < fields.Length; i++)
					fields[i].ResetPostingArrays();
				
				start = end;
			}
			
			freqOut.Close();
			proxOut.Close();
			termsOut.Close();
			
			// Record all files we have flushed
			System.Collections.IList flushedFiles = new System.Collections.ArrayList();
			flushedFiles.Add(SegmentFileName(IndexFileNames.FIELD_INFOS_EXTENSION));
			flushedFiles.Add(SegmentFileName(IndexFileNames.FREQ_EXTENSION));
			flushedFiles.Add(SegmentFileName(IndexFileNames.PROX_EXTENSION));
			flushedFiles.Add(SegmentFileName(IndexFileNames.TERMS_EXTENSION));
			flushedFiles.Add(SegmentFileName(IndexFileNames.TERMS_INDEX_EXTENSION));
			
			if (hasNorms)
			{
				WriteNorms(segmentName, numDocsInRAM);
				flushedFiles.Add(SegmentFileName(IndexFileNames.NORMS_EXTENSION));
			}
			
			if (infoStream != null)
			{
				long newSegmentSize = SegmentSize(segmentName);
				System.String message = String.Format(nf, "  oldRAMSize={0:d} newFlushedSize={1:d} docs/MB={2:f} new/old={3:%}",
					new Object[] { numBytesUsed, newSegmentSize, (numDocsInRAM / (newSegmentSize / 1024.0 / 1024.0)), (newSegmentSize / numBytesUsed) });
				infoStream.WriteLine(message);
			}
			
			ResetPostingsData();
			
			nextDocID = 0;
			nextWriteDocID = 0;
			numDocsInRAM = 0;
			files = null;
			
			// Maybe downsize postingsFreeList array
			if (postingsFreeList.Length > 1.5 * postingsFreeCount)
			{
				int newSize = postingsFreeList.Length;
				while (newSize > 1.25 * postingsFreeCount)
				{
					newSize = (int) (newSize * 0.8);
				}
				Posting[] newArray = new Posting[newSize];
				Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount);
				postingsFreeList = newArray;
			}
			
			return flushedFiles;
		}
        public static void MostrarColeccionesNoGenerics()
        {
            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("*****Pilas No Genéricas*******");
            Console.WriteLine("******************************");
            Console.ReadLine();

            //DECLARO E INSTANCIO UNA COLECCION DE TIPO LIFO
            System.Collections.Stack pila = new System.Collections.Stack();

            pila.Push(1);
            pila.Push(2);
            pila.Push(3);
            pila.Push(4);

            Console.WriteLine("Agrego elementos a la pila...");
            Console.WriteLine("Utilizo pila.Push()");
            Console.WriteLine("Orden de los elementos: 1 - 2 - 3 - 4");
            Console.ReadLine();

            Console.WriteLine("Muestro el primer elemento de la pila...");
            Console.WriteLine("Utilizo pila.Peek()");
            Console.ReadLine();

            Console.WriteLine(pila.Peek());
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos de la pila...");
            Console.WriteLine("Recorro con un foreach. No saco los elementos de la pila.");
            Console.ReadLine();

            foreach (int elemento in pila)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Desapilo todos los elementos de la pila...");
            Console.WriteLine("Utilizo pila.Pop(). Recorro con un for");
            Console.ReadLine();

            int cantidad = pila.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, pila.Pop());
            }

            Console.ReadLine();

            Console.WriteLine("Cantidad de elementos en la pila = {0}", pila.Count);
            Console.ReadLine();


            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("****Colas No Genéricas********");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.Queue cola = new System.Collections.Queue();

            cola.Enqueue(1);
            cola.Enqueue(2);
            cola.Enqueue(3);
            cola.Enqueue(4);

            Console.WriteLine("Agrego elementos a la cola...");
            Console.WriteLine("Utilizo pila.Enqueue()");
            Console.WriteLine("Orden de los elementos: 1 - 2 - 3 - 4");
            Console.ReadLine();

            Console.WriteLine("Muestro el primer elemento de la cola...");
            Console.WriteLine("Utilizo cola.Peek()");
            Console.ReadLine();

            Console.WriteLine(cola.Peek());
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos de la cola...");
            Console.WriteLine("Recorro con un foreach");
            Console.ReadLine();

            foreach (int elemento in cola)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Saco todos los elementos de la cola...");
            Console.WriteLine("Utilizo cola.Dequeue(). Recorro con un for");
            Console.ReadLine();

            cantidad = cola.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, cola.Dequeue());
            }

            Console.ReadLine();

            Console.WriteLine("Cantidad de elementos en la cola = {0}", cola.Count);
            Console.ReadLine();



            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("******Listas Dinamicas********");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.ArrayList vec = new System.Collections.ArrayList();

            vec.Add(1);
            vec.Add(4);
            vec.Add(3);
            vec.Add(2);

            Console.WriteLine("Agrego elementos al ArrayList...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del ArrayList...");
            Console.WriteLine("Recorro con un foreach");
            Console.ReadLine();

            foreach (int elemento in vec)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Sort(). Recorro con un for");
            Console.ReadLine();

            vec.Sort();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Reverse(). Recorro con un for");
            Console.ReadLine();

            vec.Reverse();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("*********HashTable************");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.Hashtable ht = new System.Collections.Hashtable();

            ht.Add(1, "valor 1");
            ht.Add(4, "valor 4");
            ht.Add(3, "valor 3");
            ht.Add(2, "valor 2");

            Console.WriteLine("Agrego elementos al HashTable...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del HashTable...");
            Console.WriteLine("Recorro con un for");
            Console.ReadLine();

            cantidad = ht.Count;

            for (int i = 1; i <= cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, ht[i]);
            }

            Console.ReadLine();
        }
Example #26
0
        public override OutputQueueData getOutputdata()
        {
            System.Collections.ArrayList ary = new System.Collections.ArrayList();
            byte[] boardid = new byte[]{1,2,3};
            string[] traveltime = new string[] { " ", " ", " " };
            byte[] colors = new byte[] { 255, 255, 255 };
            OutputQueueData ret;

            if (outputQueue.Count == 0)
                return null;
            else
            {

                System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
                while (ie.MoveNext())
                {
                    OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                    ary.Add(quedata);

                }
            }

            ary.Sort();
            if (ary.Count == 0)
                return null;
            else if (ary.Count == 1)
            {
             RemoteInterface.HC.TTSOutputData data   = (TTSOutputData)((OutputQueueData)ary[ary.Count - 1]).data;

                for (int i = 0; i < data.boardid.Length; i++)
                {
                    boardid[data.boardid[i] - 1] = data.boardid[i];
                    traveltime[data.boardid[i] - 1] = data.traveltime[i];
                    colors[data.boardid[i] - 1] = data.color[i];
                }

            }
            else
            {

                for (int qinx = ary.Count - 1; qinx >= 0; qinx--)
                {
                    RemoteInterface.HC.TTSOutputData data = (TTSOutputData)((OutputQueueData)ary[qinx]).data;
                    for (int i = 0; i < data.boardid.Length; i++)
                    {

                        if (colors[data.boardid[i] - 1] == 255 && data.color[i]!=255)
                        {
                            boardid[data.boardid[i] - 1] = data.boardid[i];
                            traveltime[data.boardid[i] - 1] = data.traveltime[i];
                            colors[data.boardid[i] - 1] = data.color[i];
                        }
                    }

                }
                //for (int i = 0; i < data.boardid.Length; i++)
                //{
                //    boardid[data.boardid[i] - 1] = data.boardid[i];
                //    traveltime[data.boardid[i] - 1] = data.traveltime[i];
                //    colors[data.boardid[i] - 1] = data.color[i];
                //}
                //data = (TTSOutputData)((OutputQueueData)ary[ary.Count - 1]).data;
                //for (int i = 0; i < data.boardid.Length; i++)
                //{
                //    boardid[data.boardid[i] - 1] = data.boardid[i];
                //    traveltime[data.boardid[i] - 1] = data.traveltime[i];
                //    colors[data.boardid[i] - 1] = data.color[i];
                //}
            }

            ret = new OutputQueueData(this.deviceName,((OutputQueueData)ary[ary.Count - 1]).mode, ((OutputQueueData)ary[ary.Count - 1]).ruleid, ((OutputQueueData)ary[ary.Count - 1]).priority
                , new TTSOutputData(boardid, traveltime, colors));
            return ret;
               // object[] data = ary.ToArray();
            //if (this.deviceName == "CMS-T78-W-41.6")
            //    Console.WriteLine("stop here");

              //  return (OutputQueueData)data[data.Length - 1];
        }
        /// <summary>
        /// �����ʽ������һ���ṩʱ�����ش�����ת����������ڵ��������͵ı�׼ֵ���ϡ�
        /// </summary>
        /// <param name="context">�ṩ��ʽ�����ĵ� ITypeDescriptorContext����������ȡ�йش��е��ô�ת�����Ļ����ĸ�����Ϣ���˲����������Կ���Ϊ�����á�</param>
        /// <returns>������׼��Чֵ���� TypeConverter.StandardValuesCollection������������Ͳ�֧�ֱ�׼ֵ������Ϊ�����á�</returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            System.Collections.ArrayList list=new System.Collections.ArrayList();

            foreach(System.ComponentModel.IComponent componet in context.Container.Components)
            {
                if(componet is  ButtonEx)
                {
                    list.Add(((ButtonEx)componet).ID);
                }
            }

            list.Sort();

            return new StandardValuesCollection(list.ToArray());
        }
Example #28
0
        public static void lblResult(System.Collections.Hashtable raceStat, string datFile, string raceDir, infoRace currInfoRace)
        {
            int maxLap=0;
            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            double[] percent = new double[] { 100, 100.5, 101.75, 103, 105.25, 107 };
            string[] colPercent = new string[] { "#7070FF", "#20F0C0", "#A0F00F", "#FFFF70", "#FFA070", "#FF5090" };

            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            raceStats.modeSort = (int)sortRaceStats.SORT_RESULT;
            sorted.Sort();
            long bestLap = 0;
            string racerBestLap = "";
            for (int i = 0; i < sorted.Count; i++)
            {
                raceStats p = (raceStats)sorted[i];
                if (p.bestLap == 0)
                    continue;
                if (bestLap == 0 || (p.bestLap < bestLap))
                {
                    bestLap = p.bestLap;
                    racerBestLap = p.nickName;
                }
                if( p.lap.Count > maxLap)
                    maxLap = p.lap.Count;
            }

            System.IO.StreamWriter sw = new System.IO.StreamWriter(raceDir + "/" + datFile + "_lbl_race.html");
            System.IO.StreamReader sr = new System.IO.StreamReader("./templates/html_lbl_race.tpl");
            string readLine;
            string wreadLine;

            while (true)
            {
                readLine = sr.ReadLine();
                if (readLine == null)
                    break;
                if (readLine.IndexOf("[Percent") == 0)
                {
                    for (int i = 0; i <= percent.GetUpperBound(0); i++)
                    {
                        wreadLine = readLine;
                        wreadLine = wreadLine.Replace("[Percent ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        wreadLine = wreadLine.Replace("{Percent}", percent[i].ToString() );
                        wreadLine = wreadLine.Replace("{percbackcolor}", colPercent[i]);
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[Headpos") == 0)
                {
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        wreadLine = wreadLine.Replace("[Headpos ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        wreadLine = wreadLine.Replace("{Pos}", (i + 1).ToString());
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }
                if (readLine.IndexOf("[Headracer") == 0)
                {
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        wreadLine = wreadLine.Replace("[Headracer ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        wreadLine = wreadLine.Replace("{Racer}", lfsStripColor((sorted[i] as raceStats).nickName) );
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }

                if (readLine.IndexOf("[[Resultracer") == 0)
                {
                    System.Collections.ArrayList blockSplit = new System.Collections.ArrayList();
                    blockSplit.Add(readLine);
                    while (true)
                    {
                        readLine = sr.ReadLine();
                        if (readLine == null)
                            break;
                        if (readLine.IndexOf("]]") != -1)
                        {
                            blockSplit.Add(readLine);
                            break;
                        }
                        blockSplit.Add(readLine);
                    }
                    for (int j = 0; j < maxLap; j++)
                    {
                        for (int k = 0; k < blockSplit.Count; k++)
                        {
                            readLine = (string)blockSplit[k];
                            if (readLine.IndexOf("[Resultline") == 0)
                            {
                                for (int i = 0; i < sorted.Count; i++)
                                {
                                    raceStats p = (raceStats)sorted[i];
                                    wreadLine = readLine;
                                    wreadLine = wreadLine.Replace("[Resultline ", "");
                                    wreadLine = wreadLine.Replace("]", "");
                                    if (p.lap.Count > j)
                                    {
                                        int bgcolor = -1;
                                        for (int z = 0; z <= percent.GetUpperBound(0); z++)
                                        {
                                            double comp = (double)bestLap * percent[z] / (double)100;
                                            if ((p.lap[j] as Lap).lapTime <= (int)comp)
                                            {
                                                bgcolor = z;
                                                goto exitfor;
                                            }
                                        }
                                    exitfor:
                                        if( bgcolor == -1 )
                                            wreadLine = wreadLine.Replace("{Bgcolor}", "white");
                                        else
                                            wreadLine = wreadLine.Replace("{Bgcolor}", colPercent[bgcolor]);
                                        wreadLine = wreadLine.Replace("{Ltime}", raceStats.LfstimeToString((p.lap[j] as Lap).lapTime));
                                    }
                                    else
                                    {
                                        wreadLine = wreadLine.Replace("{Bgcolor}", "white");
                                        wreadLine = wreadLine.Replace("{Ltime}", "");
                                    }
                                    sw.WriteLine(wreadLine);
                                }
                                continue;
                            }
                            wreadLine = readLine;
                            wreadLine = updateGlob(wreadLine, datFile, currInfoRace, "race");
                            wreadLine = wreadLine.Replace("[[Resultracer ", "");
                            wreadLine = wreadLine.Replace("]]", "");
                            wreadLine = wreadLine.Replace("{lap}", (j + 1).ToString());
                            sw.WriteLine(wreadLine);
                        }
                    }
                    continue;
                }
                if (readLine.IndexOf("[Total") == 0)
                {
                    long firstTotalTime=0;
                    int firstMaxLap=0;
                    for (int i = 0; i < sorted.Count; i++)
                    {
                        wreadLine = readLine;
                        raceStats p = (raceStats)sorted[i];
                        if (i == 0)
                        {
                            firstTotalTime = p.totalTime;
                            firstMaxLap = p.lap.Count;
                        }
                        wreadLine = wreadLine.Replace("[Total ", "");
                        wreadLine = wreadLine.Replace("]", "");
                        // if Racer do not finish
                        if (p.resultNum == 999)
                            wreadLine = wreadLine.Replace("{Gap}", "DNF");
                        else
                        {
                            if (firstMaxLap == p.lap.Count)
                            {
                                if (i == 0)
                                    wreadLine = wreadLine.Replace("{Gap}", raceStats.LfstimeToString(p.totalTime));
                                else
                                {
                                    long tres;
                                    tres = p.totalTime - firstTotalTime;
                                    wreadLine = wreadLine.Replace("{Gap}", "+" + raceStats.LfstimeToString(tres));
                                }
                            }
                            else
                                wreadLine = wreadLine.Replace("{Gap}", "+" + ((int)(firstMaxLap - p.lap.Count)).ToString() + " laps");
                        }
                        wreadLine = wreadLine.Replace("{Ttime}", raceStats.LfstimeToString(p.totalTime));
                        wreadLine = wreadLine.Replace("{Penalty}", p.penalty);
                        sw.WriteLine(wreadLine);
                    }
                    continue;
                }

                readLine = updateGlob(readLine, datFile, currInfoRace, "race");
                readLine = readLine.Replace("{Bestlap}", raceStats.LfstimeToString(bestLap) );
                readLine = readLine.Replace("{Racerbestlap}", lfsStripColor( racerBestLap));

                sw.WriteLine(readLine);
            }

            sw.Close();
            sr.Close();
        }
Example #29
0
        protected OutputQueueData[] GetPriorityQueueData(System.Collections.IComparer I_compare)
        {
            System.Collections.ArrayList ary = new System.Collections.ArrayList();
            if (outputQueue.Count == 0)
                return new OutputQueueData[0];
            else
            {

                System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
                while (ie.MoveNext())
                {
                    OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                    ary.Add(quedata);
                }

            }

            ary.Sort(I_compare);
            OutputQueueData[] data = new OutputQueueData[ary.Count];
            for (int i = 0; i < ary.Count; i++)
                data[i] = ary[i] as OutputQueueData;

            return data;
        }
Example #30
0
        public static void tsvResult(System.Collections.Hashtable raceStat, string datFile, string raceDir, infoRace currInfoRace)
        {
            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            raceStats.modeSort = (int)sortRaceStats.SORT_GRID;
            sorted.Sort();
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(raceDir + "/" + datFile + "_results_race_extended.tsv"))
            {
                sw.WriteLine(currInfoRace.maxSplit + 1);

                for (int i = 0; i < sorted.Count; i++)
                {
                    raceStats p = (raceStats)sorted[i];

                    sw.Write(p.nickName.Replace("^0", "").Replace("^1", "").Replace("^2", "").Replace("^3", "").Replace("^4", "").Replace("^5", "").Replace("^6", "").Replace("^7", "").Replace("^8", ""));
                    long lastCumul = 0;
                    for (int j = 0; j < p.lap.Count; j++)
                    {
            // case of last Lap not completed
                        if ((p.lap[j] as Lap).lapTime == 0)
                            continue;
                        if (currInfoRace.maxSplit >= 1)
                        {
                            sw.Write("\t" + (lastCumul + (p.lap[j] as Lap).split1) * 10);
                            //                            sw.Write("(" + LfstimeToString((p.lap[j] as Lap).split1) + "," + LfstimeToString((p.lap[j] as Lap).lapTime) + ")");
                        }
                        if (currInfoRace.maxSplit >= 2)
                        {
                            sw.Write("\t" + (lastCumul + (p.lap[j] as Lap).split2) * 10);
                        }
                        if (currInfoRace.maxSplit >= 3)
                        {
                            sw.Write("\t" + (lastCumul + (p.lap[j] as Lap).split3) * 10);
                        }
                        sw.Write("\t" + (lastCumul + (p.lap[j] as Lap).lapTime) * 10);
                        lastCumul = lastCumul + (p.lap[j] as Lap).lapTime;
                    }
                    sw.Write("\r\n");
                }
            }
        }
Example #31
0
		/// <summary> Tests that a query matches the an expected set of documents using Hits.
		/// 
		/// <p/>
		/// Note that when using the Hits API, documents will only be returned
		/// if they have a positive normalized score.
		/// <p/>
		/// </summary>
		/// <param name="query">the query to test
		/// </param>
		/// <param name="searcher">the searcher to test the query against
		/// </param>
		/// <param name="defaultFieldName">used for displaing the query in assertion messages
		/// </param>
		/// <param name="results">a list of documentIds that must match the query
		/// </param>
		/// <seealso cref="Searcher.Search(Query)">
		/// </seealso>
		/// <seealso cref="checkHitCollector">
		/// </seealso>
		public static void  CheckHits_Renamed_Method(Query query, System.String defaultFieldName, Searcher searcher, int[] results)
		{
			if (searcher is IndexSearcher)
			{
				QueryUtils.Check(query, searcher);
			}
			
			ScoreDoc[] hits = searcher.Search(query, null, 1000).scoreDocs;
			
			System.Collections.ArrayList correct = new System.Collections.ArrayList();
			for (int i = 0; i < results.Length; i++)
			{
                SupportClass.CollectionsHelper.AddIfNotContains(correct, results[i]);
			}
            correct.Sort();
			
			System.Collections.ArrayList actual = new System.Collections.ArrayList();
			for (int i = 0; i < hits.Length; i++)
			{
				SupportClass.CollectionsHelper.AddIfNotContains(actual, hits[i].doc);
			}
            actual.Sort();
			
			Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
			
			QueryUtils.Check(query, searcher);
		}
Example #32
0
        public static void csvResult( System.Collections.Hashtable raceStat, string datFile, string raceDir, infoRace currInfoRace )
        {
            string formatLine;
            int firstMaxLap = 0;
            long firstTotalTime = 0;

            using (System.IO.StreamReader sr = new System.IO.StreamReader("templates/csv_race.tpl"))
            {
                formatLine = sr.ReadLine();
                if (formatLine == null)
                    formatLine = "[RaceResults {Position},{PlayerName},{UserName},{Car},{Gap},{BestLap},{LapsDone},{PitsDone},{Penalty},{Flags}]";
            }
            System.Collections.ArrayList sorted = new System.Collections.ArrayList();
            System.Collections.IDictionaryEnumerator tmpRaceStat = raceStat.GetEnumerator();
            while (tmpRaceStat.MoveNext())	//for each player
            {
                raceStats p = (raceStats)tmpRaceStat.Value;
                sorted.Add(p);
            }
            raceStats.modeSort = (int)sortRaceStats.SORT_RESULT;
            sorted.Sort();
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(raceDir + "/" + datFile + "_results_race.csv"))
            {
                int curPos = 0;
                for (int i = 0; i < sorted.Count; i++)
                {
                    curPos++;
                    raceStats p = (raceStats)sorted[i];
                    if (i == 0)
                    {
                        firstMaxLap = p.lap.Count;
                        firstTotalTime = p.totalTime;
                    }
                    string resultLine = formatLine;
                    resultLine = resultLine.Replace("[RaceResults ", "");
                    resultLine = resultLine.Replace("]", "");
                    resultLine = resultLine.Replace("{Position}", curPos.ToString());
                    //                    resultLine = resultLine.Replace("{Position}", p.resultNum.ToString() );
                    resultLine = resultLine.Replace("{PlayerName}", p.nickName.Replace("^0", "").Replace("^1", "").Replace("^2", "").Replace("^3", "").Replace("^4", "").Replace("^5", "").Replace("^6", "").Replace("^7", "").Replace("^8", ""));
                    resultLine = resultLine.Replace("{UserName}", p.userName);
                    resultLine = resultLine.Replace("{Car}", p.CName);
                    // if Racer do not finish
                    if (p.resultNum == 999)
                        resultLine = resultLine.Replace("{Gap}", "DNF");
                    else
                    {
                        if (firstMaxLap == p.lap.Count)
                        {
                            if (i == 0)
                                resultLine = resultLine.Replace("{Gap}", raceStats.LfstimeToString(p.totalTime));
                            else
                            {
                                long tres;
                                tres = p.totalTime - firstTotalTime;
                                resultLine = resultLine.Replace("{Gap}", "+" + raceStats.LfstimeToString(tres));
                            }
                        }
                        else
                            resultLine = resultLine.Replace("{Gap}", "+" + ((int)(firstMaxLap - p.lap.Count)).ToString() + " laps");
                    }
                    resultLine = resultLine.Replace("{BestLap}", raceStats.LfstimeToString(p.bestLap));
                    resultLine = resultLine.Replace("{LapsDone}", p.lap.Count.ToString());
                    resultLine = resultLine.Replace("{PitsDone}", p.numStop.ToString());
                    resultLine = resultLine.Replace("{Penalty}", p.penalty);
                    resultLine = resultLine.Replace("{PosGrid}", p.gridPos.ToString());
                    resultLine = resultLine.Replace("{Flags}", p.sFlags);
                    sw.WriteLine(resultLine);
                }
            }
        }
        public static void MostrarColeccionesNoGenerics()
        {
            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("*****Pilas No Genéricas*******");
            Console.WriteLine("******************************");
            Console.ReadLine();

            //DECLARO E INSTANCIO UNA COLECCION DE TIPO LIFO
            System.Collections.Stack pila = new System.Collections.Stack();

            pila.Push(1);
            pila.Push(2);
            pila.Push(3);
            pila.Push(4);

            Console.WriteLine("Agrego elementos a la pila...");
            Console.WriteLine("Utilizo pila.Push()");
            Console.WriteLine("Orden de los elementos: 1 - 2 - 3 - 4");
            Console.ReadLine();

            Console.WriteLine("Muestro el primer elemento de la pila...");
            Console.WriteLine("Utilizo pila.Peek()");
            Console.ReadLine();

            Console.WriteLine(pila.Peek());
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos de la pila...");
            Console.WriteLine("Recorro con un foreach. No saco los elementos de la pila.");
            Console.ReadLine();

            foreach (int elemento in pila)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Desapilo todos los elementos de la pila...");
            Console.WriteLine("Utilizo pila.Pop(). Recorro con un for");
            Console.ReadLine();

            int cantidad = pila.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, pila.Pop());
            }

            Console.ReadLine();

            Console.WriteLine("Cantidad de elementos en la pila = {0}", pila.Count);
            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("****Colas No Genéricas********");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.Queue cola = new System.Collections.Queue();

            cola.Enqueue(1);
            cola.Enqueue(2);
            cola.Enqueue(3);
            cola.Enqueue(4);

            Console.WriteLine("Agrego elementos a la cola...");
            Console.WriteLine("Utilizo pila.Enqueue()");
            Console.WriteLine("Orden de los elementos: 1 - 2 - 3 - 4");
            Console.ReadLine();

            Console.WriteLine("Muestro el primer elemento de la cola...");
            Console.WriteLine("Utilizo cola.Peek()");
            Console.ReadLine();

            Console.WriteLine(cola.Peek());
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos de la cola...");
            Console.WriteLine("Recorro con un foreach");
            Console.ReadLine();

            foreach (int elemento in cola)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Saco todos los elementos de la cola...");
            Console.WriteLine("Utilizo cola.Dequeue(). Recorro con un for");
            Console.ReadLine();

            cantidad = cola.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, cola.Dequeue());
            }

            Console.ReadLine();

            Console.WriteLine("Cantidad de elementos en la cola = {0}", cola.Count);
            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("******Listas Dinamicas********");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.ArrayList vec = new System.Collections.ArrayList();

            vec.Add(1);
            vec.Add(4);
            vec.Add(3);
            vec.Add(2);

            Console.WriteLine("Agrego elementos al ArrayList...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del ArrayList...");
            Console.WriteLine("Recorro con un foreach");
            Console.ReadLine();

            foreach (int elemento in vec)
            {
                Console.WriteLine(elemento);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Sort(). Recorro con un for");
            Console.ReadLine();

            vec.Sort();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.WriteLine("Ordeno los elementos del ArrayList...");
            Console.WriteLine("Utilizo vec.Reverse(). Recorro con un for");
            Console.ReadLine();

            vec.Reverse();

            cantidad = vec.Count;

            for (int i = 0; i < cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, vec[i]);
            }

            Console.ReadLine();

            Console.Clear();
            Console.WriteLine("******************************");
            Console.WriteLine("*********HashTable************");
            Console.WriteLine("******************************");
            Console.ReadLine();

            System.Collections.Hashtable ht = new System.Collections.Hashtable();

            ht.Add(1, "valor 1");
            ht.Add(4, "valor 4");
            ht.Add(3, "valor 3");
            ht.Add(2, "valor 2");

            Console.WriteLine("Agrego elementos al HashTable...");
            Console.WriteLine("Utilizo vec.Add()");
            Console.WriteLine("Orden de los elementos: 1 - 4 - 3 - 2");
            Console.ReadLine();

            Console.WriteLine("Muestro todos los elementos del HashTable...");
            Console.WriteLine("Recorro con un for");
            Console.ReadLine();

            cantidad = ht.Count;

            for (int i = 1; i <= cantidad; i++)
            {
                Console.WriteLine("Elemento {0} = {1}", i, ht[i]);
            }

            Console.ReadLine();
        }
		private Control GetEditorControl (object value)
		{
			TabControl tab_control = new TabControl();
			tab_control.Dock = DockStyle.Fill;
			TabPage custom_tab = new TabPage("Custom");
			TabPage web_tab = new TabPage("Web");
			TabPage system_tab = new TabPage("System");

			ColorListBox web_listbox = new ColorListBox();
			ColorListBox system_listbox = new ColorListBox();
			web_listbox.Dock = DockStyle.Fill;
			system_listbox.Dock = DockStyle.Fill;

			web_tab.Controls.Add(web_listbox);
			system_tab.Controls.Add(system_listbox);

			SystemColorCompare system_compare = new SystemColorCompare();
			System.Collections.ArrayList color_list = new System.Collections.ArrayList();
			foreach (System.Reflection.PropertyInfo property in typeof(SystemColors).GetProperties(System.Reflection.BindingFlags.Public |System.Reflection.BindingFlags.Static)) {
				Color clr = (Color)property.GetValue(null,null);
				color_list.Add(clr);
			}
			color_list.Sort(system_compare);
			system_listbox.Items.AddRange(color_list.ToArray());
			system_listbox.MouseUp+=new MouseEventHandler(HandleMouseUp);
			system_listbox.SelectedValueChanged+=new EventHandler(HandleChange);

			WebColorCompare web_compare = new WebColorCompare();
			color_list = new System.Collections.ArrayList();
			foreach (KnownColor known_color in Enum.GetValues(typeof(KnownColor))) 
			{
				Color color = Color.FromKnownColor(known_color);
				if (color.IsSystemColor)
					continue;
				color_list.Add(color);
			}
			color_list.Sort(web_compare);
			web_listbox.Items.AddRange(color_list.ToArray());
			web_listbox.MouseUp+=new MouseEventHandler(HandleMouseUp);
			web_listbox.SelectedValueChanged+=new EventHandler(HandleChange);

			CustomColorPicker custom_picker = new CustomColorPicker ();
			custom_picker.Dock = DockStyle.Fill;
			custom_picker.ColorChanged += new EventHandler (CustomColorPicked);
			custom_tab.Controls.Add (custom_picker);

			tab_control.TabPages.Add(custom_tab);
			tab_control.TabPages.Add(web_tab);
			tab_control.TabPages.Add(system_tab);

			if (value != null) {
				Color current_color = (Color)value;
				if (current_color.IsSystemColor) 
				{
					system_listbox.SelectedValue = current_color;
					tab_control.SelectedTab = system_tab;
				}
				else if (current_color.IsKnownColor)
				{
					web_listbox.SelectedValue = current_color;
					tab_control.SelectedTab = web_tab;
				}
				selected_color = current_color;
				color_chosen = true;
			}

			tab_control.Height = 216; // the height of the custom colors tab
			return tab_control;
		}
Example #35
0
        private clsOutpatientPrintRecipe_VO m_mthGetPrintVo(string strID)
        {
            clsOutpatientPrintRecipe_VO obj_VO = new clsOutpatientPrintRecipe_VO();

            objSvc = new clsDcl_ShowReports();
            DataTable dt;
            long      ret = objSvc.m_mthGetRecipeInfo(strID, out dt);

            if (ret > 0 && dt.Rows.Count > 0)
            {
                obj_VO.m_strDiagDeptID  = dt.Rows[0]["DEPTNAME_CHR"].ToString().Trim();
                obj_VO.m_strDiagDrName  = dt.Rows[0]["DOCTORNAME_CHR"].ToString().Trim();
                obj_VO.m_strRegisterID  = "";
                obj_VO.m_strSelfPay     = dt.Rows[0]["SBSUM_MNY"].ToString().Trim();
                obj_VO.m_strChargeUp    = dt.Rows[0]["ACCTSUM_MNY"].ToString().Trim();
                obj_VO.m_strRecipePrice = dt.Rows[0]["TOTALSUM_MNY"].ToString().Trim();
                obj_VO.m_strPrintDate   = dt.Rows[0]["INVDATE_DAT"].ToString().Trim().Substring(0, 10);
                obj_VO.m_strAddress     = dt.Rows[0]["HOMEADDRESS_VCHR"].ToString().Trim();
                obj_VO.m_strGOVCARD     = dt.Rows[0]["GOVCARD_CHR"].ToString().Trim();
                obj_VO.m_strINSURANCEID = dt.Rows[0]["INSURANCEID_VCHR"].ToString().Trim();
                DateTime dteBirth = Convert.ToDateTime(dt.Rows[0]["BIRTH_DAT"].ToString());
                obj_VO.m_strAge                 = clsCreatFile.s_strCalAge(dteBirth);
                obj_VO.m_strCardID              = dt.Rows[0]["PATIENTCARDID_CHR"].ToString().Trim();
                obj_VO.m_strHospitalName        = strHospitalName;
                obj_VO.m_strPatientName         = dt.Rows[0]["LASTNAME_VCHR"].ToString().Trim();
                obj_VO.m_strSex                 = dt.Rows[0]["SEX_CHR"].ToString().Trim();
                obj_VO.m_strRecipeType          = dt.Rows[0]["RECIPEFLAG_INT"].ToString().Trim();
                obj_VO.m_strHerbalmedicineUsage = "";
                obj_VO.strInvoiceNO             = dt.Rows[0]["INVOICENO_VCHR"].ToString().Trim();
                obj_VO.m_strRecordEmpID         = dt.Rows[0]["TYPENAME_VCHR"].ToString().Trim();
                obj_VO.m_strPatientType         = dt.Rows[0]["PAYTYPENAME_VCHR"].ToString().Trim();
                obj_VO.m_strdiagnose            = dt.Rows[0]["DIAG_VCHR"].ToString().Trim();
            }



            obj_VO.m_strTimes = "1";

            obj_VO.m_strRecipeID = strID;

            clsDcl_DoctorWorkstation objDKSvc = new clsDcl_DoctorWorkstation();

            dt = null;
            decimal decWMedicineCost  = 0;
            decimal decZCMedicineCost = 0;
            decimal decCureCost       = 0;

            System.Collections.ArrayList objPRDArr = new System.Collections.ArrayList();
            string[] IDarr = null;
            objSvc.m_mthGetRecipeGroup(strID, out IDarr);
            foreach (string TempID in IDarr)
            {
                ret = objDKSvc.m_mthFindRecipeDetail1(TempID, out dt, true);             //西药
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME_VCHR"].ToString().Trim();
                        objtemp.m_strCount      = dt.Rows[i]["TOLQTY_DEC"].ToString().Trim() + dt.Rows[i]["UNITID_CHR"].ToString();
                        objtemp.m_strPrice      = clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["UNITPRICE_MNY"]).ToString("0.00");
                        objtemp.m_strSumPrice   = dt.Rows[i]["TOLPRICE_MNY"].ToString().Trim();
                        objtemp.m_strUnit       = dt.Rows[i]["DOSAGEUNIT_CHR"].ToString().Trim();
                        objtemp.m_strFrequency  = dt.Rows[i]["FREQNAME_CHR"].ToString().Trim();
                        objtemp.m_strDosage     = dt.Rows[i]["QTY_DEC"].ToString().Trim() + dt.Rows[i]["DOSAGEUNIT_CHR"].ToString().Trim();
                        objtemp.m_strDays       = dt.Rows[i]["DAYS_INT"].ToString().Trim();
                        objtemp.m_strSpec       = dt.Rows[i]["ITEMSPEC_VCHR"].ToString().Trim();
                        objtemp.m_strUsage      = dt.Rows[i]["USAGENAME_VCHR"].ToString().Trim();
                        objtemp.m_strRowNo      = dt.Rows[i]["ROWNO_CHR"].ToString().Trim();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        decWMedicineCost       += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["TOLPRICE_MNY"]);
                        objPRDArr.Add(objtemp);
                    }
                }
            }

            System.Collections.ArrayList objPRDArr2 = new   System.Collections.ArrayList();
            foreach (string TempID in IDarr)
            {
                ret = objDKSvc.m_mthFindRecipeDetail2(TempID, out dt, true);             //中药
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME"].ToString().Trim();
                        objtemp.m_strDosage     = dt.Rows[i]["MIN_QTY_DEC"].ToString().Trim() + dt.Rows[i]["UNIT"].ToString();
                        objtemp.m_strPrice      = dt.Rows[i]["price"].ToString().Trim();
                        objtemp.m_strSumPrice   = dt.Rows[i]["SUMMONEY"].ToString().Trim();
                        objtemp.m_strUsage      = dt.Rows[i]["USAGENAME_VCHR"].ToString();
                        objtemp.m_strRowNo      = dt.Rows[i]["ROWNO_CHR"].ToString();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        decZCMedicineCost      += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["SUMMONEY"]);
                        objPRDArr2.Add(objtemp);
                    }
                }
            }


            obj_VO.objinjectArr = new System.Collections.ArrayList();
            foreach (string TempID in IDarr)
            {
                ret = objDKSvc.m_mthFindRecipeDetail3(TempID, out dt, true);
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME"].ToString();;
                        objtemp.m_strCount      = dt.Rows[i]["quantity"].ToString().Trim();
                        objtemp.m_strPrice      = dt.Rows[i]["PRICE"].ToString();
                        objtemp.m_strSumPrice   = dt.Rows[i]["SUMMONEY"].ToString().Trim();
                        objtemp.m_strUnit       = dt.Rows[i]["UNIT"].ToString().Trim();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        objtemp.m_strFrequency  = "";
                        objtemp.m_strDosage     = "";
                        objtemp.m_strDays       = "";
                        objtemp.m_strUsage      = "";
                        objtemp.m_strRowNo      = "";
                        decCureCost            += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["SUMMONEY"]);
                        obj_VO.objinjectArr.Add(objtemp);
                    }
                }
                ret = objDKSvc.m_mthFindRecipeDetail4(TempID, out dt, true);
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME"].ToString();;
                        objtemp.m_strCount      = dt.Rows[i]["quantity"].ToString().Trim();
                        objtemp.m_strPrice      = dt.Rows[i]["PRICE"].ToString();
                        objtemp.m_strSumPrice   = dt.Rows[i]["SUMMONEY"].ToString().Trim();
                        objtemp.m_strUnit       = dt.Rows[i]["UNIT"].ToString().Trim();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        objtemp.m_strFrequency  = "";
                        objtemp.m_strDosage     = "";
                        objtemp.m_strDays       = "";
                        objtemp.m_strUsage      = "";
                        objtemp.m_strRowNo      = "";
                        decCureCost            += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["SUMMONEY"]);
                        obj_VO.objinjectArr.Add(objtemp);
                    }
                }
                ret = objDKSvc.m_mthFindRecipeDetail5(TempID, out dt, true);
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME"].ToString();;
                        objtemp.m_strCount      = dt.Rows[i]["quantity"].ToString().Trim();
                        objtemp.m_strPrice      = dt.Rows[i]["PRICE"].ToString();
                        objtemp.m_strSumPrice   = dt.Rows[i]["SUMMONEY"].ToString().Trim();
                        objtemp.m_strUnit       = dt.Rows[i]["UNIT"].ToString().Trim();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        objtemp.m_strFrequency  = "";
                        objtemp.m_strDosage     = "";
                        objtemp.m_strDays       = "";
                        objtemp.m_strUsage      = "";
                        objtemp.m_strRowNo      = "";
                        decCureCost            += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["SUMMONEY"]);
                        obj_VO.objinjectArr.Add(objtemp);
                    }
                }
                ret = objDKSvc.m_mthFindRecipeDetail6(TempID, out dt, true);
                if (ret > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsOutpatientPrintRecipeDetail_VO objtemp = new clsOutpatientPrintRecipeDetail_VO();
                        objtemp.m_strChargeName = dt.Rows[i]["ITEMNAME"].ToString();;
                        objtemp.m_strCount      = dt.Rows[i]["quantity"].ToString().Trim();
                        objtemp.m_strPrice      = dt.Rows[i]["PRICE"].ToString();
                        objtemp.m_strSumPrice   = dt.Rows[i]["SUMMONEY"].ToString().Trim();
                        objtemp.m_strUnit       = dt.Rows[i]["UNIT"].ToString().Trim();
                        objtemp.m_strInvoiceCat = dt.Rows[i]["ITEMOPINVTYPE_CHR"].ToString().Trim();
                        objtemp.m_strFrequency  = "";
                        objtemp.m_strDosage     = "";
                        objtemp.m_strDays       = "";
                        objtemp.m_strUsage      = "";
                        objtemp.m_strRowNo      = "";
                        decCureCost            += clsConvertToDecimal.m_mthConvertObjToDecimal(dt.Rows[i]["SUMMONEY"]);
                        obj_VO.objinjectArr.Add(objtemp);
                    }
                }
            }
            obj_VO.m_strWMedicineCost  = decWMedicineCost.ToString("0.00");         //最后在这里添加数据
            obj_VO.m_strZCMedicineCost = decZCMedicineCost.ToString("0.00");
            obj_VO.m_strCureCost       = decCureCost.ToString("0.00");
            objPRDArr.Sort(0, objPRDArr.Count, null);
            objPRDArr2.Sort(0, objPRDArr2.Count, null);
            obj_VO.objPRDArr  = objPRDArr;
            obj_VO.objPRDArr2 = objPRDArr2;
            return(obj_VO);
        }
Example #36
0
        //-----------------------------------------------------------------


        internal static Array DirectoryEntries(Frame caller, System.IO.DirectoryInfo cd)
        {
            System.IO.FileSystemInfo[] infos = cd.GetFileSystemInfos();

            System.Collections.ArrayList names = new System.Collections.ArrayList();

            names.Add(new String("."));
            names.Add(new String(".."));

            for (int i = 0; i < infos.Length; i++)
                names.Add(new String(infos[i].Name));

            names.Sort(new String.CaseInsensitiveComparer(caller));

            return new Array(names);
        }
Example #37
0
        static void Main(string[] args)
        {
            Console.Title = "Ejercicio 27";

            Random r = new Random();

            #region Pilas
            Console.WriteLine("Pilas");
            System.Collections.Stack pila = new System.Collections.Stack();

            for (int i = 0; i < 20; i++)
            {
                pila.Push(r.Next(100, 200));
            }

            Console.WriteLine("Mostrar como se ingresó");
            MostrarPila(pila);

            Console.WriteLine("\nMostrar de forma decreciente");
            pila = SortStack(pila, false);
            MostrarPila(pila);

            Console.WriteLine("\nMostrar de forma creciente");
            pila = SortStack(pila, true);
            MostrarPila(pila);

            Console.ReadLine();
            #endregion
            Console.Clear();

            #region Colas
            Console.WriteLine("Colas");
            System.Collections.Queue cola = new System.Collections.Queue();

            for (int i = 0; i < 20; i++)
            {
                cola.Enqueue(r.Next(100, 200));
            }

            Console.WriteLine("Mostrar como se ingresó");
            MostrarCola(cola);

            Console.WriteLine("\nMostrar de forma decreciente");
            cola = SortQueue(cola, true);
            MostrarCola(cola);

            Console.WriteLine("\nMostrar de forma creciente");
            cola = SortQueue(cola, false);
            MostrarCola(cola);

            Console.ReadLine();
            #endregion
            Console.Clear();

            #region Listas
            Console.WriteLine("Listas");
            System.Collections.ArrayList lista = new System.Collections.ArrayList();

            for (int i = 0; i < 20; i++)
            {
                lista.Add(r.Next(100, 200));
            }

            Console.WriteLine("Mostrar como se ingresó");
            MostrarLista(lista);

            Console.WriteLine("\nMostrar de forma decreciente");
            lista.Sort();
            lista.Reverse();
            MostrarLista(lista);

            Console.WriteLine("\nMostrar de forma creciente");
            lista.Reverse();
            MostrarLista(lista);

            Console.ReadLine();
            #endregion
        }
Example #38
0
        //public void setGenericDisplay( RGS_GenericDisplay_Data data,int ruleid,int priority )
        //{
        //    EnOutputQueue(new TC.OutputQueueData(ruleid, priority, data));
        //    output();
        //}
        //public  new   I_MFCC_RGS getRemoteObj()
        //{
        //    return (I_MFCC_RGS)base.getRemoteObj();
        //}
        public override OutputQueueData getOutputdata()
        {
            //return base.getOutputdata();

            // int maxPriority = -1000, maxRuleid = -1000;

             System.Collections.ArrayList ary = new System.Collections.ArrayList();
            // RGS_GenericDisplay_Data MergeGData;
             if (outputQueue.Count == 0)
             return null;
             else
             {

             System.Collections.IEnumerator ie = outputQueue.GetEnumerator();
             while (ie.MoveNext())
             {
                 OutputQueueData quedata = (OutputQueueData)((System.Collections.DictionaryEntry)ie.Current).Value;

                 ary.Add(quedata);
                 //if (data.priority > maxPriority)
                 //{
                 //  //  mergeGerericDisplayData
                 //    maxPriority = data.priority;
                 //    maxRuleid = data.ruleid;
                 //}
             }
             }

             ary.Sort();
             object[] data = ary.ToArray();

             if (data.Length == 1)
             return data[0] as OutputQueueData;
             else
             {
             if (((data[0] as OutputQueueData).data as RGS_GenericDisplay_Data).mode != 2)
                 return data[0] as OutputQueueData;

            // System.Collections.ArrayList upperary = new System.Collections.ArrayList();
               //  System.Collections.ArrayList lowerary = new System.Collections.ArrayList();

             OutputQueueData upperData = null;
             OutputQueueData lowerData = null;
             OutputQueueData traveData = null;
             for (int i = data.Length-1; i >=0 ; i--)
             {
                 OutputQueueData qdata = data[i] as OutputQueueData;
                 RGS_GenericDisplay_Data rgsdata = qdata.data as RGS_GenericDisplay_Data;

                 if (rgsdata.mode != 2)
                     break;
                 if (rgsdata.msgs[0].y / 128 == 0)   //upper part
                 {
                     if((data[i] as OutputQueueData).mode==  OutputModeEnum.TravelMode)
                         traveData =data[i] as OutputQueueData;

                     else if (upperData == null)
                         upperData = data[i] as OutputQueueData ;
                 }
                 else  //lower part
                 {
                      if(lowerData == null)
                          lowerData=data[i] as OutputQueueData;

                 }

             }

             if (upperData != null && lowerData != null)
                 return mergeOutputQueueData(upperData, lowerData);
             else if (upperData != null && lowerData == null)
             {
                 if (traveData == null)

                     return upperData;
                 else

                     return mergeOutputQueueData(upperData, traveData);
             }
             else if (upperData == null && lowerData != null)
             {
                 if (traveData == null)
                     return lowerData;
                 else
                     return mergeOutputQueueData(lowerData, traveData);
             }
             else if (data.Length > 0)  //直接輸出 都會路網 等非旅行時間輸出
                 return data[data.Length - 1] as OutputQueueData;
             else

                 return null;

             }

             //if(data.Length>1)
             //return  mergeOutputQueueData((OutputQueueData)data[data.Length-1],(OutputQueueData)data[data.Length-2]);
             //else
             //return (OutputQueueData)data[0];
        }
Example #39
0
        ///----------------------------------------------------------------------
        /// <summary>
        ///     2次元配列からArrayListにデータをセットする </summary>
        ///----------------------------------------------------------------------
        private System.Collections.ArrayList array2ToArrayList(clsXlsmst[] xlsArray)
        {
            System.Collections.ArrayList al = new System.Collections.ArrayList();

            for (int i = 0; i < xlsArray.Length; i++)
            {
                for (int iX = 1; iX <= xlsArray[i].xlsMst.GetLength(0); iX++)
                {
                    // 26列ないときはエリア別社員マスターシートとみなさない
                    if (xlsArray[i].xlsMst.GetLength(1) < 26)
                    {
                        continue;
                    }

                    // 使用区分が1以外はネグる
                    if (Utility.NulltoStr(xlsArray[i].xlsMst[iX, 26]).Trim() != global.FLGON)
                    {
                        continue;
                    }

                    // エリア№が空白のときネグる
                    if (Utility.NulltoStr(xlsArray[i].xlsMst[iX, 1]).Trim() == string.Empty)
                    {
                        continue;
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 1]).PadLeft(3, '0')).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 4]).PadLeft(5, '0')).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 20]).PadLeft(5, '0')).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 2])).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 5])).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 21])).Append(",");
                    sb.Append(getTimeString(xlsArray, i, iX, 8)).Append(",");
                    sb.Append(getTimeString(xlsArray, i, iX, 12)).Append(",");
                    sb.Append(getTimeString(xlsArray, i, iX, 16)).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 23])).Append(",");
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 22])).Append(",");

                    // 実労働時間
                    string wH = string.Empty;
                    string wM = string.Empty;
                    if (Utility.NulltoStr(xlsArray[i].xlsMst[iX, 24]) != string.Empty)
                    {
                        wH = Utility.NulltoStr(xlsArray[i].xlsMst[iX, 24]).PadLeft(2, ' ');
                    }

                    if (Utility.NulltoStr(xlsArray[i].xlsMst[iX, 25]) != string.Empty)
                    {
                        wM = Utility.NulltoStr(xlsArray[i].xlsMst[iX, 25]).PadLeft(2, '0');
                    }

                    if (wH != string.Empty || wM != string.Empty)
                    {
                        sb.Append(wH).Append(":").Append(wM).Append(",");
                    }
                    else
                    {
                        sb.Append(string.Empty).Append(",");
                    }

                    // エリアマネージャー名
                    sb.Append(Utility.NulltoStr(xlsArray[i].xlsMst[iX, 3]));

                    //Array.Resize(ref csvArray, iR + 1);
                    //csvArray[iR] = sb.ToString();

                    al.Add(sb.ToString());

                    //iR++;
                }
            }

            al.Sort();

            return(al);
        }
Example #40
0
 /// <summary> Return all (BaseAttribute derived) attributes in the MethodDeclaration sorted using their position. </summary>
 public virtual System.Collections.ArrayList GetSortedAttributes(System.Reflection.MemberInfo member)
 {
     System.Collections.ArrayList list = new System.Collections.ArrayList();
     if(member != null)
         foreach(object attrib in member.GetCustomAttributes(false))
             if(attrib is BaseAttribute)
                 list.Add(attrib);
     list.Sort();
     return list;
 }
Example #41
0
        ///----------------------------------------------------------------
        /// <summary>
        ///     配列からコンボボックスにロードする </summary>
        /// <param name="tempObj">
        ///     コンボボックスオブジェクト</param>
        /// <param name="fName">
        ///     CSVデータファイルパス</param>
        /// <param name="cmbKbn">
        ///     0:社員コンボボックス、1:部門コンボボックス</param>
        ///----------------------------------------------------------------
        private static void arrayCmbLoad(ComboBox tempObj, Utility.xlsShain [] x, int cmbKbn)
        {
            string tl = "";

            try
            {
                if (cmbKbn == global.flgOff)
                {
                    tl = "社員";
                }
                else
                {
                    tl = "部門";
                }

                Utility.ComboBumon cmb1;    // 部門コンボボックス
                Utility.ComboShain cmbS;    // 社員コンボボックス

                tempObj.Items.Clear();
                tempObj.DisplayMember = "DisplayName";
                tempObj.ValueMember   = "code";

                // 社員名簿配列読み込み
                System.Collections.ArrayList al = new System.Collections.ArrayList();
                string bn = "";

                foreach (var t in x)
                {
                    if (cmbKbn == global.flgOff)
                    {
                        // 社員
                        bn = t.sCode.ToString().PadLeft(5, '0') + "," + t.sName + "";
                    }
                    else
                    {
                        // 部門
                        bn = t.bCode.ToString().PadLeft(5, '0') + "," + t.bName + "";
                    }

                    al.Add(bn);
                }

                // 配列をソートします
                al.Sort();

                string alCode = string.Empty;

                foreach (var item in al)
                {
                    string[] d = item.ToString().Split(',');

                    // 重複はネグる
                    if (alCode != string.Empty && alCode.Substring(0, 5) == d[0])
                    {
                        continue;
                    }

                    // コンボボックスにセット
                    if (cmbKbn == global.flgOn)
                    {
                        // 部門コンボボックス
                        cmb1             = new Utility.ComboBumon();
                        cmb1.ID          = 0;
                        cmb1.DisplayName = item.ToString().Replace(',', ' ');

                        string[] cn = item.ToString().Split(',');
                        cmb1.Name = cn[1] + "";
                        cmb1.code = cn[0] + "";
                        tempObj.Items.Add(cmb1);
                    }
                    else if (cmbKbn == global.flgOff)
                    {
                        // 社員コンボボックス
                        cmbS             = new Utility.ComboShain();
                        cmbS.ID          = 0;
                        cmbS.DisplayName = item.ToString().Replace(',', ' ');

                        string[] cn = item.ToString().Split(',');
                        cmbS.Name = cn[1] + "";
                        cmbS.code = cn[0] + "";
                        tempObj.Items.Add(cmbS);
                    }

                    alCode = item.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, tl + "コンボボックスロード");
            }
        }
Example #42
0
        /// <summary> Write a Component XML Element from attributes in a type. </summary>
        public virtual void WriteComponent(System.Xml.XmlWriter writer, System.Type type)
        {
            object[] attributes = type.GetCustomAttributes(typeof(ComponentAttribute), false);
            if(attributes.Length == 0)
                return;
            ComponentAttribute attribute = attributes[0] as ComponentAttribute;

            writer.WriteStartElement( "component" );
            // Attribute: <class>
            if(attribute.Class != null)
            writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, type));
            // Attribute: <name>
            writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Component_Name_DefaultValue(type) : GetAttributeValue(attribute.Name, type));
            // Attribute: <access>
            if(attribute.Access != null)
            writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, type));
            // Attribute: <unique>
            if( attribute.UniqueSpecified )
            writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false");
            // Attribute: <update>
            if( attribute.UpdateSpecified )
            writer.WriteAttributeString("update", attribute.Update ? "true" : "false");
            // Attribute: <insert>
            if( attribute.InsertSpecified )
            writer.WriteAttributeString("insert", attribute.Insert ? "true" : "false");
            // Attribute: <lazy>
            if( attribute.LazySpecified )
            writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false");
            // Attribute: <optimistic-lock>
            if( attribute.OptimisticLockSpecified )
            writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false");
            // Attribute: <node>
            if(attribute.Node != null)
            writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, type));

            WriteUserDefinedContent(writer, type, null, attribute);
            // Element: <meta>
            System.Collections.ArrayList MetaList = FindAttributedMembers( attribute, typeof(MetaAttribute), type );
            foreach( System.Reflection.MemberInfo member in MetaList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MetaAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MetaAttribute), attribute);
            // Element: <tuplizer>
            System.Collections.ArrayList TuplizerList = FindAttributedMembers( attribute, typeof(TuplizerAttribute), type );
            foreach( System.Reflection.MemberInfo member in TuplizerList )
            {
                object[] objects = member.GetCustomAttributes(typeof(TuplizerAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteTuplizer(writer, member, memberAttrib as TuplizerAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(TuplizerAttribute), attribute);
            // Element: <parent>
            System.Collections.ArrayList ParentList = FindAttributedMembers( attribute, typeof(ParentAttribute), type );
            foreach( System.Reflection.MemberInfo member in ParentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ParentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteParent(writer, member, memberAttrib as ParentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ParentAttribute), attribute);
            // Element: <property>
            System.Collections.ArrayList PropertyList = FindAttributedMembers( attribute, typeof(PropertyAttribute), type );
            foreach( System.Reflection.MemberInfo member in PropertyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PropertyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PropertyAttribute), attribute);
            // Element: <many-to-one>
            System.Collections.ArrayList ManyToOneList = FindAttributedMembers( attribute, typeof(ManyToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in ManyToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ManyToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ManyToOneAttribute), attribute);
            // Element: <one-to-one>
            System.Collections.ArrayList OneToOneList = FindAttributedMembers( attribute, typeof(OneToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in OneToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(OneToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteOneToOne(writer, member, memberAttrib as OneToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(OneToOneAttribute), attribute);
            // Element: <component>
            WriteNestedComponentTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(ComponentAttribute), attribute);
            // Element: <dynamic-component>
            System.Collections.ArrayList DynamicComponentList = FindAttributedMembers( attribute, typeof(DynamicComponentAttribute), type );
            foreach( System.Reflection.MemberInfo member in DynamicComponentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(DynamicComponentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                WriteDynamicComponent(writer, member, memberAttribs[0] as DynamicComponentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(DynamicComponentAttribute), attribute);
            // Element: <any>
            System.Collections.ArrayList AnyList = FindAttributedMembers( attribute, typeof(AnyAttribute), type );
            foreach( System.Reflection.MemberInfo member in AnyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(AnyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(AnyAttribute), attribute);
            // Element: <map>
            System.Collections.ArrayList MapList = FindAttributedMembers( attribute, typeof(MapAttribute), type );
            foreach( System.Reflection.MemberInfo member in MapList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MapAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMap(writer, member, memberAttrib as MapAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MapAttribute), attribute);
            // Element: <set>
            System.Collections.ArrayList SetList = FindAttributedMembers( attribute, typeof(SetAttribute), type );
            foreach( System.Reflection.MemberInfo member in SetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSet(writer, member, memberAttrib as SetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SetAttribute), attribute);
            // Element: <list>
            System.Collections.ArrayList ListList = FindAttributedMembers( attribute, typeof(ListAttribute), type );
            foreach( System.Reflection.MemberInfo member in ListList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ListAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteList(writer, member, memberAttrib as ListAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ListAttribute), attribute);
            // Element: <bag>
            System.Collections.ArrayList BagList = FindAttributedMembers( attribute, typeof(BagAttribute), type );
            foreach( System.Reflection.MemberInfo member in BagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(BagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteBag(writer, member, memberAttrib as BagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(BagAttribute), attribute);
            // Element: <idbag>
            System.Collections.ArrayList IdBagList = FindAttributedMembers( attribute, typeof(IdBagAttribute), type );
            foreach( System.Reflection.MemberInfo member in IdBagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(IdBagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteIdBag(writer, member, memberAttrib as IdBagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(IdBagAttribute), attribute);
            // Element: <array>
            System.Collections.ArrayList ArrayList = FindAttributedMembers( attribute, typeof(ArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in ArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteArray(writer, member, memberAttrib as ArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ArrayAttribute), attribute);
            // Element: <primitive-array>
            System.Collections.ArrayList PrimitiveArrayList = FindAttributedMembers( attribute, typeof(PrimitiveArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in PrimitiveArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PrimitiveArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WritePrimitiveArray(writer, member, memberAttrib as PrimitiveArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PrimitiveArrayAttribute), attribute);

            writer.WriteEndElement();
        }
Example #43
0
        ///--------------------------------------------------------------------------
        /// <summary>
        ///     グリッドビューへ社員情報を表示する </summary>
        /// <param name="tempDGV">
        ///     DataGridViewオブジェクト名</param>
        /// <param name="sCode">
        ///     所属範囲開始コード</param>
        /// <param name="eCode">
        ///     所属範囲終了コード</param>
        /// <param name="sNo">
        ///     社員範囲開始コード</param>
        /// <param name="eNo">
        ///     社員範囲終了コード</param>
        ///--------------------------------------------------------------------------
        private void GridViewShowData(DataGridView tempDGV, int sCode, int eCode, string sNo, string eNo, string [] cArray)
        {
            try
            {
                //グリッドビューに表示する
                int iX = 0;
                tempDGV.RowCount = 0;

                System.Collections.ArrayList al = new System.Collections.ArrayList();

                foreach (var t in cArray)
                {
                    string[] f = t.Split(',');

                    if (f.Length < 4)
                    {
                        continue;
                    }

                    // 所属コード範囲指定
                    if (Utility.StrtoInt(f[3]) < sCode || Utility.StrtoInt(f[3]) > eCode)
                    {
                        continue;
                    }

                    // 社員番号範囲指定
                    int _sNo = Utility.StrtoInt(sNo);
                    int _eNo = 99999;

                    if (Utility.StrtoInt(eNo) != 0)
                    {
                        _eNo = Utility.StrtoInt(eNo);
                    }

                    if (Utility.StrtoInt(f[1]) < _sNo || Utility.StrtoInt(f[1]) > _eNo)
                    {
                        continue;
                    }

                    // 発行順
                    if (radioButton4.Checked)
                    {
                        // 社員番号順
                        al.Add(f[1] + "," + f[0] + "," + f[3] + "," + f[2] + "," + f[4]);
                    }
                    else
                    {
                        // 勤務先別、社員番号順
                        al.Add(f[3] + "," + f[2] + "," + f[1] + "," + f[0] + "," + f[4]);
                    }
                }

                al.Sort();

                foreach (var t in al)
                {
                    string [] f = t.ToString().Split(',');

                    //データグリッドにデータを表示する
                    tempDGV.Rows.Add();

                    tempDGV[0, iX].Value = true;

                    if (radioButton4.Checked)
                    {
                        // 社員番号順
                        tempDGV[1, iX].Value = f[2];
                        tempDGV[2, iX].Value = f[3];
                        tempDGV[3, iX].Value = f[0];
                        tempDGV[4, iX].Value = f[1];
                        tempDGV[5, iX].Value = f[4];
                    }
                    else
                    {
                        // 勤務先・社員番号順
                        tempDGV[1, iX].Value = f[0];
                        tempDGV[2, iX].Value = f[1];
                        tempDGV[3, iX].Value = f[2];
                        tempDGV[4, iX].Value = f[3];
                        tempDGV[5, iX].Value = f[4];
                    }

                    //tempDGV[5, iX].Value = string.Empty;

                    iX++;
                }

                tempDGV.CurrentCell = null;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
            }
            finally
            {
            }

            //社員情報がないとき
            if (tempDGV.RowCount == 0)
            {
                MessageBox.Show("社員情報が存在しません", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                btnCheckOn.Enabled  = false;
                btnCheckOff.Enabled = false;
                btnPrn.Enabled      = false;
            }
            else
            {
                btnCheckOn.Enabled  = true;
                btnCheckOff.Enabled = true;
                btnPrn.Enabled      = true;
            }
        }
Example #44
0
        /// <summary> Write a JoinedSubclass XML Element from attributes in a type. </summary>
        public virtual void WriteJoinedSubclass(System.Xml.XmlWriter writer, System.Type type)
        {
            object[] attributes = type.GetCustomAttributes(typeof(JoinedSubclassAttribute), false);
            if(attributes.Length == 0)
                return;
            JoinedSubclassAttribute attribute = attributes[0] as JoinedSubclassAttribute;

            writer.WriteStartElement( "joined-subclass" );
            // Attribute: <entity-name>
            if(attribute.EntityName != null)
            writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, type));
            // Attribute: <name>
            if(attribute.Name != null)
            writer.WriteAttributeString("name", GetAttributeValue(attribute.Name, type));
            // Attribute: <proxy>
            if(attribute.Proxy != null)
            writer.WriteAttributeString("proxy", GetAttributeValue(attribute.Proxy, type));
            // Attribute: <table>
            if(attribute.Table != null)
            writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, type));
            // Attribute: <schema>
            if(attribute.Schema != null)
            writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, type));
            // Attribute: <catalog>
            if(attribute.Catalog != null)
            writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, type));
            // Attribute: <subselect>
            if(attribute.Subselect != null)
            writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, type));
            // Attribute: <dynamic-update>
            if( attribute.DynamicUpdateSpecified )
            writer.WriteAttributeString("dynamic-update", attribute.DynamicUpdate ? "true" : "false");
            // Attribute: <dynamic-insert>
            if( attribute.DynamicInsertSpecified )
            writer.WriteAttributeString("dynamic-insert", attribute.DynamicInsert ? "true" : "false");
            // Attribute: <select-before-update>
            if( attribute.SelectBeforeUpdateSpecified )
            writer.WriteAttributeString("select-before-update", attribute.SelectBeforeUpdate ? "true" : "false");
            // Attribute: <extends>
            if(attribute.Extends != null)
            writer.WriteAttributeString("extends", GetAttributeValue(attribute.Extends, type));
            // Attribute: <lazy>
            if( attribute.LazySpecified )
            writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false");
            // Attribute: <abstract>
            if( attribute.AbstractSpecified )
            writer.WriteAttributeString("abstract", attribute.Abstract ? "true" : "false");
            // Attribute: <persister>
            if(attribute.Persister != null)
            writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, type));
            // Attribute: <check>
            if(attribute.Check != null)
            writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, type));
            // Attribute: <batch-size>
            if(attribute.BatchSize != -1)
            writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString());
            // Attribute: <node>
            if(attribute.Node != null)
            writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, type));

            WriteUserDefinedContent(writer, type, null, attribute);
            // Element: <meta>
            System.Collections.ArrayList MetaList = FindAttributedMembers( attribute, typeof(MetaAttribute), type );
            foreach( System.Reflection.MemberInfo member in MetaList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MetaAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MetaAttribute), attribute);
            // Element: <subselect>
            System.Collections.ArrayList SubselectList = FindAttributedMembers( attribute, typeof(SubselectAttribute), type );
            foreach( System.Reflection.MemberInfo member in SubselectList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SubselectAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SubselectAttribute), attribute);
            // Element: <synchronize>
            System.Collections.ArrayList SynchronizeList = FindAttributedMembers( attribute, typeof(SynchronizeAttribute), type );
            foreach( System.Reflection.MemberInfo member in SynchronizeList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SynchronizeAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SynchronizeAttribute), attribute);
            // Element: <comment>
            System.Collections.ArrayList CommentList = FindAttributedMembers( attribute, typeof(CommentAttribute), type );
            foreach( System.Reflection.MemberInfo member in CommentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(CommentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(CommentAttribute), attribute);
            // Element: <tuplizer>
            System.Collections.ArrayList TuplizerList = FindAttributedMembers( attribute, typeof(TuplizerAttribute), type );
            foreach( System.Reflection.MemberInfo member in TuplizerList )
            {
                object[] objects = member.GetCustomAttributes(typeof(TuplizerAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteTuplizer(writer, member, memberAttrib as TuplizerAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(TuplizerAttribute), attribute);
            // Element: <key>
            System.Collections.ArrayList KeyList = FindAttributedMembers( attribute, typeof(KeyAttribute), type );
            foreach( System.Reflection.MemberInfo member in KeyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(KeyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(KeyAttribute), attribute);
            // Element: <property>
            System.Collections.ArrayList PropertyList = FindAttributedMembers( attribute, typeof(PropertyAttribute), type );
            foreach( System.Reflection.MemberInfo member in PropertyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PropertyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PropertyAttribute), attribute);
            // Element: <many-to-one>
            System.Collections.ArrayList ManyToOneList = FindAttributedMembers( attribute, typeof(ManyToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in ManyToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ManyToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ManyToOneAttribute), attribute);
            // Element: <one-to-one>
            System.Collections.ArrayList OneToOneList = FindAttributedMembers( attribute, typeof(OneToOneAttribute), type );
            foreach( System.Reflection.MemberInfo member in OneToOneList )
            {
                object[] objects = member.GetCustomAttributes(typeof(OneToOneAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteOneToOne(writer, member, memberAttrib as OneToOneAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(OneToOneAttribute), attribute);
            // Element: <component>
            WriteNestedComponentTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(ComponentAttribute), attribute);
            // Element: <dynamic-component>
            System.Collections.ArrayList DynamicComponentList = FindAttributedMembers( attribute, typeof(DynamicComponentAttribute), type );
            foreach( System.Reflection.MemberInfo member in DynamicComponentList )
            {
                object[] objects = member.GetCustomAttributes(typeof(DynamicComponentAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                WriteDynamicComponent(writer, member, memberAttribs[0] as DynamicComponentAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(DynamicComponentAttribute), attribute);
            // Element: <properties>
            System.Collections.ArrayList PropertiesList = FindAttributedMembers( attribute, typeof(PropertiesAttribute), type );
            foreach( System.Reflection.MemberInfo member in PropertiesList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PropertiesAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteProperties(writer, member, memberAttrib as PropertiesAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PropertiesAttribute), attribute);
            // Element: <any>
            System.Collections.ArrayList AnyList = FindAttributedMembers( attribute, typeof(AnyAttribute), type );
            foreach( System.Reflection.MemberInfo member in AnyList )
            {
                object[] objects = member.GetCustomAttributes(typeof(AnyAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(AnyAttribute), attribute);
            // Element: <map>
            System.Collections.ArrayList MapList = FindAttributedMembers( attribute, typeof(MapAttribute), type );
            foreach( System.Reflection.MemberInfo member in MapList )
            {
                object[] objects = member.GetCustomAttributes(typeof(MapAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteMap(writer, member, memberAttrib as MapAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(MapAttribute), attribute);
            // Element: <set>
            System.Collections.ArrayList SetList = FindAttributedMembers( attribute, typeof(SetAttribute), type );
            foreach( System.Reflection.MemberInfo member in SetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSet(writer, member, memberAttrib as SetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SetAttribute), attribute);
            // Element: <list>
            System.Collections.ArrayList ListList = FindAttributedMembers( attribute, typeof(ListAttribute), type );
            foreach( System.Reflection.MemberInfo member in ListList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ListAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteList(writer, member, memberAttrib as ListAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ListAttribute), attribute);
            // Element: <bag>
            System.Collections.ArrayList BagList = FindAttributedMembers( attribute, typeof(BagAttribute), type );
            foreach( System.Reflection.MemberInfo member in BagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(BagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteBag(writer, member, memberAttrib as BagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(BagAttribute), attribute);
            // Element: <idbag>
            System.Collections.ArrayList IdBagList = FindAttributedMembers( attribute, typeof(IdBagAttribute), type );
            foreach( System.Reflection.MemberInfo member in IdBagList )
            {
                object[] objects = member.GetCustomAttributes(typeof(IdBagAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteIdBag(writer, member, memberAttrib as IdBagAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(IdBagAttribute), attribute);
            // Element: <array>
            System.Collections.ArrayList ArrayList = FindAttributedMembers( attribute, typeof(ArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in ArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteArray(writer, member, memberAttrib as ArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ArrayAttribute), attribute);
            // Element: <primitive-array>
            System.Collections.ArrayList PrimitiveArrayList = FindAttributedMembers( attribute, typeof(PrimitiveArrayAttribute), type );
            foreach( System.Reflection.MemberInfo member in PrimitiveArrayList )
            {
                object[] objects = member.GetCustomAttributes(typeof(PrimitiveArrayAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WritePrimitiveArray(writer, member, memberAttrib as PrimitiveArrayAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(PrimitiveArrayAttribute), attribute);
            // Element: <joined-subclass>
            WriteNestedJoinedSubclassTypes(writer, type);
            WriteUserDefinedContent(writer, type, typeof(JoinedSubclassAttribute), attribute);
            // Element: <loader>
            System.Collections.ArrayList LoaderList = FindAttributedMembers( attribute, typeof(LoaderAttribute), type );
            foreach( System.Reflection.MemberInfo member in LoaderList )
            {
                object[] objects = member.GetCustomAttributes(typeof(LoaderAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(LoaderAttribute), attribute);
            // Element: <sql-insert>
            System.Collections.ArrayList SqlInsertList = FindAttributedMembers( attribute, typeof(SqlInsertAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlInsertList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlInsertAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlInsertAttribute), attribute);
            // Element: <sql-update>
            System.Collections.ArrayList SqlUpdateList = FindAttributedMembers( attribute, typeof(SqlUpdateAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlUpdateList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlUpdateAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlUpdateAttribute), attribute);
            // Element: <sql-delete>
            System.Collections.ArrayList SqlDeleteList = FindAttributedMembers( attribute, typeof(SqlDeleteAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlDeleteList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlDeleteAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlDeleteAttribute), attribute);
            // Element: <resultset>
            System.Collections.ArrayList ResultSetList = FindAttributedMembers( attribute, typeof(ResultSetAttribute), type );
            foreach( System.Reflection.MemberInfo member in ResultSetList )
            {
                object[] objects = member.GetCustomAttributes(typeof(ResultSetAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteResultSet(writer, member, memberAttrib as ResultSetAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(ResultSetAttribute), attribute);
            // Element: <query>
            System.Collections.ArrayList QueryList = FindAttributedMembers( attribute, typeof(QueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in QueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(QueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteQuery(writer, member, memberAttrib as QueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(QueryAttribute), attribute);
            // Element: <sql-query>
            System.Collections.ArrayList SqlQueryList = FindAttributedMembers( attribute, typeof(SqlQueryAttribute), type );
            foreach( System.Reflection.MemberInfo member in SqlQueryList )
            {
                object[] objects = member.GetCustomAttributes(typeof(SqlQueryAttribute), false);
                System.Collections.ArrayList memberAttribs = new System.Collections.ArrayList();
                memberAttribs.AddRange(objects);
                memberAttribs.Sort();
                foreach(object memberAttrib in memberAttribs)
                    WriteSqlQuery(writer, member, memberAttrib as SqlQueryAttribute, attribute, type);
            }
            WriteUserDefinedContent(writer, type, typeof(SqlQueryAttribute), attribute);

            writer.WriteEndElement();
        }
Example #45
0
        protected void Page_Load(object sender, EventArgs e)
        {
            player = Wc3o.Game.CurrentPlayer;

            if (Request.QueryString["League"] != null) {

                DataTable ranking = new DataTable();
                ranking.Columns.Add("Rank", typeof(String));
                ranking.Columns.Add("Name", typeof(String));
                ranking.Columns.Add("Score", typeof(String));

                if (Request.QueryString["League"] == "0") {
                    pnlPlayer.Visible = false;
                    pnlAlliance.Visible = true;
                    ranking.Columns.Add("Members", typeof(String));
                    ranking.Columns.Add("Average", typeof(String));

                    System.Collections.ArrayList alliances = new System.Collections.ArrayList();
                    foreach (Alliance a in Wc3o.Game.GameData.Alliances.Values)
                        alliances.Add(a);

                    alliances.Sort(new Wc3o.AllianceScoreComparer());
                    int rank = 1;

                    foreach (Alliance alliance in alliances) {
                        int numberOfMembers = alliance.AcceptedMembers.Count;
                        int score = alliance.Score;
                        if (numberOfMembers > 0 && score > 0) {

                            string rankFormat = "<div>";
                            string userFormat = "<div>";

                            if (player.Alliance == alliance)
                                userFormat = "<div style='color:" + Configuration.Color_Ally + "'>";
                            else
                                userFormat = "<div style='color:" + Configuration.Color_Enemy + "'>";

                            if (rank == 1)
                                rankFormat = "<div style='font-size:19px;'>";
                            else if (rank == 2)
                                rankFormat = "<div style='font-size:17px;'>";
                            else if (rank == 3)
                                rankFormat = "<div style='font-size:15px;'>";
                            else if (rank < 11)
                                rankFormat = "<div style='font-size:13px;'>";
                            else
                                rankFormat = "<div style='font-size:11xp;'>";

                            DataRow row = ranking.NewRow();
                            row["Rank"] = rankFormat + userFormat + Wc3o.Game.Format(rank) + "</div></div>";
                            row["Name"] = "<a href='AllianceInfo.aspx?Alliance=" + alliance.Name + "'>" + rankFormat + userFormat + alliance.FullName + "</div></div></a>";
                            row["Score"] = rankFormat + userFormat + Wc3o.Game.Format(score) + "</div></div>";
                            row["Members"] = rankFormat + userFormat + Wc3o.Game.Format(numberOfMembers) + "</div></div>";
                            row["Average"] = rankFormat + userFormat + Wc3o.Game.Format((int)(alliance.Score / numberOfMembers)) + "</div></div>";
                            ranking.Rows.Add(row);
                            rank++;
                        }
                    }

                    grdAlliance.DataSource = ranking;
                    grdAlliance.DataBind();
                }
                else {
                    pnlPlayer.Visible = true;
                    pnlAlliance.Visible = false;
                    ranking.Columns.Add("Image", typeof(String));

                    int league = int.Parse(Request.QueryString["League"]);
                    List<Player> players = new List<Player>();
                    foreach (Player p in Wc3o.Game.GetPlayers(league))
                        players.Add(p);
                    players.Sort(new PlayerScoreComparer());

                    #region " Checks if the given league is valid "
                    int rankedPlayers = 0;
                    foreach (Player p in Wc3o.Game.GameData.Players.Values)
                        if (p.Score > 0)
                            rankedPlayers++;

                    int maxLeague = Wc3o.Game.GetLeague(rankedPlayers);
                    if (league > maxLeague || league < 0)
                        Response.Redirect("Ranking.aspx?League=" + player.League, true);
                    #endregion

                    #region " Fills lblLeague and lblLeagues "
                    for (int i = 1; i <= maxLeague; i++)
                        if (i != league)
                            lblLeagues.Text += "[<a href='Ranking.aspx?League=" + i.ToString() + "'>League " + i + "</a>] ";
                    lblLeague.Text = Wc3o.Game.Format(league);
                    #endregion

                    foreach (Player p in players) {
                        string rankFormat = "";
                        string userFormat = "";

                        if (player == p)
                            userFormat = "<div style='color:" + Configuration.Color_Player + "'>";
                        else if (player.IsAlly(p))
                            userFormat = "<div style='color:" + Configuration.Color_Ally + "'>";
                        else if (player.CanAttack(p))
                            userFormat = "<div style='color:" + Configuration.Color_Enemy + "'>";
                        else
                            userFormat = "<div style='color:" + Configuration.Color_League + "'>";

                        if (p.Rank == 1)
                            rankFormat = "<div style='font-size:19px;'>";
                        else if (p.Rank == 2)
                            rankFormat = "<div style='font-size:17px;'>";
                        else if (p.Rank == 3)
                            rankFormat = "<div style='font-size:15px;'>";
                        else if (p.Rank < 11)
                            rankFormat = "<div style='font-size:13px;'>";
                        else
                            rankFormat = "<div style='font-size:11px;'>";

                        DataRow row = ranking.NewRow();
                        row["Rank"] = rankFormat + userFormat + Wc3o.Game.Format(p.Rank) + "</div></div>";
                        row["Name"] = rankFormat + userFormat + p.FullName + "</div></div>";
                        row["Score"] = rankFormat + userFormat + Wc3o.Game.Format(p.Score) + "</div></div>";
                        row["Image"] = "<a href='PlayerInfo.aspx?Player=" + p.Name + "'><img src='" + player.Gfx + "/" + p.FractionInfo.SmallEmblem + "' /></a>";
                        ranking.Rows.Add(row);
                    }

                    grdPlayer.DataSource = ranking;
                    grdPlayer.DataBind();

                    if (lblLeagues.Text == "")
                        lblLeagues.Visible = false;
                }

                int numberOfUnrankedPlayers = 0;
                foreach (Player p in Wc3o.Game.GameData.Players.Values)
                    if (p.Score <= 0)
                        numberOfUnrankedPlayers++;
                if (numberOfUnrankedPlayers == 1)
                    lblUnranked.Text = "<b>" + Wc3o.Game.Format(numberOfUnrankedPlayers) + " Player</b> has no score and is";
                else
                    lblUnranked.Text = "<b>" + Wc3o.Game.Format(numberOfUnrankedPlayers) + " Players</b> have no score and are";

            }
            else {
                int l = player.League;
                if (l == 0) l = 1;
                Response.Redirect("Ranking.aspx?League=" + l, true);
            }

            lblRankingTick.Text = Wc3o.Game.TimeSpan(Wc3o.Game.GameData.Ticks.RankingTick);
        }
Example #46
0
		/// <summary>
		/// Main routine to call and run the process.
		/// </summary>
		/// <returns></returns>
		static int DoTheWork()
		{
			m_NL = Sfm2Xml.Converter.WideToMulti(System.Environment.NewLine, System.Text.Encoding.ASCII);

			if (m_OutputFileName == null)// || File.Exists
			{
				m_OutputFileName = Path.GetTempFileName();	// get a temporaryfile name and full path
				Console.WriteLine("Created temp file for output: " + m_OutputFileName);
//				m_createdTempFile = true;
			}

			FileStream outputFile = new FileStream(m_OutputFileName, FileMode.Create);
			BinaryWriter bWriter = new BinaryWriter(outputFile);

			try
			{
				// collect the statistics from the file
				Sfm2Xml.SfmFileReaderEx reader = new Sfm2Xml.SfmFileReaderEx(m_FileName);
				int[] byteCounts = reader.GetByteCounts;

				// get a sorted list of sfm values
				System.Collections.ArrayList sfmSorted = new System.Collections.ArrayList(reader.SfmInfo);
				sfmSorted.Sort();
				RemoveSFMsFromByteCount(ref byteCounts, sfmSorted, reader);
				bWriter.Write(MakeBytes(OutputHeader()));
				OutputByteCountInfo(byteCounts, bWriter);
				OutputSfmInfo(sfmSorted, bWriter, reader);
				OutputFollowedByInfo(sfmSorted, bWriter, reader);
			}
			finally
			{
				if (bWriter != null)
					bWriter.Close();
				if (outputFile != null)
					outputFile.Close();
			}
			return 0;
		}
Example #47
0
        /* Standard A* */
        public bool Astar_start(AstarNode startNode, AstarNode targetNode)
        {
            System.Collections.ArrayList closedlist = new System.Collections.ArrayList();
            System.Collections.ArrayList openlist   = new System.Collections.ArrayList();

            closedlist.Clear();
            openlist.Clear();
            startNode.fvalue = calcFvalue(startNode); //this sets g and h

            openlist.Add(startNode);

            while (openlist.Count > 0)
            {
                Globals.debugPath = pathNodes;
                AstarNode xNode;
                openlist.Sort();
                xNode = ((AstarNode)openlist[0]);
                if (xNode == targetNode)
                {
                    pathNodes.Add(xNode);
                    return(true);
                }
                openlist.Remove(xNode);
                closedlist.Add(xNode);
                pathNodes.Add(xNode);
                findAdjacentNodes(xNode);

                foreach (AstarNode yNode in xNode.adjacentNodes)
                {
                    if (closedlist.Contains(yNode))
                    {
                        continue;
                    }
                    int  tempGScore;
                    bool isBetter = false;

                    //todo add diagonals.
                    tempGScore   = xNode.gvalue + HorizontalCost;
                    yNode.fvalue = calcFvalue(yNode);

                    if (openlist.Contains(yNode))
                    {
                        openlist.Add(yNode);
                        isBetter = true;
                    }
                    else if (tempGScore < yNode.gvalue)
                    {
                        isBetter = true;
                    }

                    else
                    {
                        isBetter = false;
                    }
                    if (isBetter)
                    {
                        yNode.gvalue = tempGScore;
                        yNode.hvalue = calcHvalue(yNode);
                        yNode.fvalue = yNode.gvalue + yNode.hvalue;
                    }
                }
            }
            return(false);
        }