コード例 #1
0
    void AddItem(int storeid, int buytimes)
    {
        StoreConfig sc = ArkCrossEngine.StoreConfigProvider.Instance.GetDataById(storeid);

        if (sc != null)
        {
            if (storeDic.ContainsKey(storeid))
            {
                storeInfo si = storeDic[storeid];
                if (si != null)
                {
                    SetGameObjectInfo(si.go, sc, sc.m_HaveDayLimit ? sc.m_DayLimit - buytimes : 1);
                    si.ChangeTimes(sc.m_HaveDayLimit ? sc.m_DayLimit - buytimes : 1);
                }
            }
            else
            {
                UnityEngine.GameObject go = GetAGameObject();
                NGUITools.SetActive(go, true);
                if (go != null)
                {
                    go.transform.name = string.Format("{0:D5}", storeid);
                    UIEventListener.Get(go).onClick = StoreItemClick;
                    SetGameObjectInfo(go, sc, sc.m_HaveDayLimit ? sc.m_DayLimit - buytimes : 1);
                    storeDic.Add(storeid, new storeInfo(sc.m_HaveDayLimit ? sc.m_DayLimit - buytimes : 1, storeid, go));
                }
            }
        }
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: ChuntaChen/TestAdnroid
        static void Main(string[] args)
        {
            Console.SetWindowSize(150, 48);              // set cmd window size

            string projectName = getDeviceInfo("Model"); // get project name

            projectName = getCorrectProjectName(projectName);

            string CurrentDir = System.Environment.CurrentDirectory;

            outputFile = CurrentDir + @"\" + projectName + "_Driver_Comparison_Report.txt";
            outResult  = new FileInfo(outputFile);

            DriverDumpFile  = CurrentDir + @"\" + projectName + "_Drivers_Dump.txt";
            outDriverDump   = new FileInfo(DriverDumpFile);
            driverDumpWrite = outDriverDump.CreateText();

            Win32DumpFile  = CurrentDir + @"\" + projectName + "_Win32Apps_Dump.txt";
            outWin32Dump   = new FileInfo(Win32DumpFile);
            Win32DumpWrite = outWin32Dump.CreateText();

            resultWrite = outResult.CreateText();

            resultWrite.WriteLine("Project: " + projectName);
            Console.WriteLine("Project: " + projectName);

            string OSVersion = getOSInfo("BuildNumber");  // get OS version, like as 16299, 17134 ... etc

            resultWrite.WriteLine("OS Version: " + OSVersion);
            Console.WriteLine("OS Version: " + OSVersion);

            string CPUName = getCPUInfo("Name");

            resultWrite.WriteLine("CPU Name: " + CPUName);
            Console.WriteLine("CPU Name: " + CPUName);

            double memoryTotal = Convert.ToDouble(getDeviceInfo("TotalPhysicalMemory")); // get total memory

            memoryTotal = Math.Round(memoryTotal / Math.Pow(2, 30), 0);                  // covert to GB unit
            resultWrite.WriteLine("Memory: " + memoryTotal + "GB");
            Console.WriteLine("Memory: " + memoryTotal + "GB");

            storeInfo[] diskInfo = new storeInfo[2];
            getDiskInfo(diskInfo);
            Console.Write("Disk: " + diskInfo[0].name + "\tSize: " + Math.Round(Convert.ToDouble(diskInfo[0].version) / Math.Pow(2, 30), 0) + " GB\tFree Space: ");
            resultWrite.Write("Disk: " + diskInfo[0].name + "\tSize: " + Math.Round(Convert.ToDouble(diskInfo[0].version) / Math.Pow(2, 30), 0) + " GB\tFree Space: ");
            if (diskInfo[1].name == null && diskInfo[1].version == null) // if only C drive, get C drive free space
            {
                Console.WriteLine(Math.Round(Convert.ToDouble(getLogicalDiskInfo(0)) / Math.Pow(2, 30), 0) + " GB");
                resultWrite.WriteLine(Math.Round(Convert.ToDouble(getLogicalDiskInfo(0)) / Math.Pow(2, 30), 0) + " GB");
            }
            else   //if exist both C and D drives  , get D drive free space
            {
                Console.WriteLine(Math.Round(Convert.ToDouble(getLogicalDiskInfo(1)) / Math.Pow(2, 30), 0) + " GB");
                resultWrite.WriteLine(Math.Round(Convert.ToDouble(getLogicalDiskInfo(1)) / Math.Pow(2, 30), 0) + " GB");
            }

            if (diskInfo[1].name != null && diskInfo[1].version != null) // if exist D drive, get C drive info
            {
                Console.WriteLine("Disk: " + diskInfo[1].name + "  Size: " + Math.Round(Convert.ToDouble(diskInfo[1].version) / Math.Pow(2, 30), 0) + " GB\tFree Space: "
                                  + Math.Round(Convert.ToDouble(getLogicalDiskInfo(0)) / Math.Pow(2, 30), 0) + " GB");
                resultWrite.WriteLine("Disk: " + diskInfo[1].name + "  Size: " + Math.Round(Convert.ToDouble(diskInfo[1].version) / Math.Pow(2, 30), 0) + " GB\tFree Space: "
                                      + Math.Round(Convert.ToDouble(getLogicalDiskInfo(0)) / Math.Pow(2, 30), 0) + " GB");
            }

            resultWrite.WriteLine();
            Console.WriteLine();

            ManagementClass            getDriver = new ManagementClass("Win32_PnPSigneddriver");
            ManagementObjectCollection collectDriverInstances = getDriver.GetInstances();

            driverInfo = new storeInfo[collectDriverInstances.Count];
            Console.WriteLine("Getting all drivers' name and version ....");
            Console.WriteLine();
            getDriverInDevice(collectDriverInstances);  // get all driver name and version, and store in array driverInfo

            ManagementClass            getWin32App             = new ManagementClass("Win32_Product");
            ManagementObjectCollection collecWin32AppInstances = getWin32App.GetInstances();

            win32AppInfo = new storeInfo[collecWin32AppInstances.Count];
            Console.WriteLine("Getting all Win32 Apps' name and version ....");
            Console.WriteLine();
            getWin32AppInDevice(collecWin32AppInstances);  // get all Win32 app name and version, and store in array win32AppInfo

            Stream xmlStrm = null;

            xmlStrm = getXMLFile(xmlStrm, projectName, OSVersion); // get xml file stream

            xmltype[] dataArray = new xmltype[30];
            if (xmlStrm != null)
            {
                parserXMLFile(xmlStrm, dataArray);
            }

            // output result and file
            resultWrite.WriteLine("------------------------- Result of Comparison -------------------------");
            Console.WriteLine("------------------------- Result of Comparison -------------------------");
            resultWrite.WriteLine();
            Console.WriteLine();
            printDash();
            printResultArr(0);
            printDash();

            int resultValue = 0;

            storeInfo[][] sourceInfo = { driverInfo, win32AppInfo };
            //FileInfo[] sourceInfo = { outDriverDump, outWin32Dump };
            //storeInfo[][] sourceInfo = { win32AppInfo, driverInfo };
            for (int i = 0; i < dataArray.Length; i++)
            {
                if (dataArray[i].name != null)
                {
                    /*
                     * Console.WriteLine("Name: " + dataArray[i].name + "  Version: "
                     + dataArray[i].version + "  Vendor: " + dataArray[i].vendor
                     + "Driver Name: " + dataArray[i].driver);
                     */
                    outputDataResult.driver      = dataArray[i].driver;
                    outputDataResult.version     = dataArray[i].version;
                    outputDataResult.vendor      = dataArray[i].vendor;
                    outputDataResult.verInDevice = "";
                    outputDataResult.result      = "";

                    for (int j = 0; j < sourceInfo.Length; j++)
                    {
                        resultValue = compareFun(sourceInfo[j], dataArray[i].driver, dataArray[i].version);
                        //resultValue = compareFunFile(sourceInfo[j], dataArray[i].driver, dataArray[i].version);
                        if (resultValue != 0)
                        {
                            break;
                        }
                    }

                    // special case
                    if (resultValue != 1)
                    {
                        resultValue = specialCase(dataArray[i].driver, dataArray[i].version, dataArray[i].vendor, dataArray[i].name, resultValue);
                    }

                    if (resultValue == 0)
                    {
                        outputDataResult.result = "Not Found";
                    }

                    printResultArr(1);
                    printDash();
                }
            }

            resultWrite.Flush();
            resultWrite.Close();

            Console.WriteLine();
            Console.WriteLine("Done and Generated Report in Current Directory .....");
            Console.Read();
        }