Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //!!删除指定目录下的所有的txt文件日志文件
            WriteLog.DeleteLog();

            //! 1.根据命令行中的值,初始化hook
            //! 1、解析参数,更新初始值
            argsPrase(args);

            //! 2、初始化数据库链接信息
            ClientConn.PraseDataBaseConfig(!HookHelper.method.Equals("wata")); //解析配置文件,并建立数据库连接。
            ClientConn.PraseTableTypeConfig();                                 //解析数据库对应要解析的表类型链接
            ClientConn.PraseComputerTableConfig();

            //!3、 初始化与数据库相关的hookhelper变量
            InitHookHelper(args);


            //CSVLog
            string serverIP = Program.GetLocalIP(HookHelper.serachIP);
            string hostName = Dns.GetHostName();
            string path     = ConfigurationManager.AppSettings["CSVLogPath"].ToString()
                              + "\\" + hostName.ToString() + "_" + serverIP.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";

            if (HookHelper.useCSVLOG.Equals("true"))
            {
                CSVData.CSVInit(path);
            }



            //testEXEListening();

            try
            {
                string[] nodes = new string[] { HookHelper.computerNode };
                if (HookHelper.computerNode.ToUpper().Equals("ALLNODE"))
                {
                    nodes = new string[] { "ComputeNode1", "ComputeNode2", "ComputeNode3", "ComputeNode4", "ComputeNode5", "ComputeNode6", "ComputeNode7", "ComputeNode8", "ComputeNode9", "ComputeNode10", "ComputeNode11" };
                }

                //! 设置计时器,所有节点时间累加值
                Stopwatch totalNodeFolderDat = new Stopwatch();
                totalNodeFolderDat.Start();
                for (int i = 0; i < nodes.Length; ++i)
                {
                    HookHelper.computerNode = nodes[i];
                    //! 为了后续计算速度快,提前从数据库中读取unit单元信息和模型路径信息,
                    if (HookHelper.method.Equals("wata"))
                    {
                        ClientConn.PraseGridUnitConfigAllChina(HookHelper.computerNode);
                    }
                    else
                    {
                        ClientConn.PraseGridUnitConfig();
                    }


                    // 每个省对应一个数据库连接,每个连接里包含了降雨切片目录
                    Dictionary <string, Dictionary <string, string> >    dbValues       = ClientConn.m_dbTableTypes;
                    Dictionary <string, Dictionary <string, DataTable> > dbTableConfigs = ClientConn.m_dbTableConfig;

                    if (HookHelper.method == "province")
                    {
                        CalcOneByOne.runBySingleCC();
                        //执行插入日志
                        WriteLog.WriteLogMethod(HookHelper.Log, "runByCCFolder");
                        break;
                    }

                    if (HookHelper.method == "wata")
                    {
                        //WriteUnitInfo.GetAllHsfxUnitTableByWATA();

                        if (HookHelper.processModel.ToUpper().Equals("NORMAL"))
                        {
                            CalcOneByOneWata.runBySingleCC();
                        }
                        else
                        {
                            CalcOneByOneWata.runBySingleCCADD();
                        }

                        //执行插入日志
                        WriteLog.WriteLogMethod(HookHelper.Log, "runByCCFolder");
                    }

                    //! 阻塞程序不关闭
                    Console.WriteLine(string.Format("当前主机节点{0}网格计算调度完成  ", HookHelper.computerNode) + DateTime.Now);

                    //执行插入日志
                    WriteLog.WriteLogMethod(HookHelper.Log);
                    Console.WriteLine(string.Format("####################################################################") + DateTime.Now);
                    Console.WriteLine(string.Format("                                                                    ") + DateTime.Now);
                    Console.WriteLine(string.Format("                                                                    ") + DateTime.Now);
                    Console.WriteLine(string.Format("####################################################################") + DateTime.Now);
                }
                totalNodeFolderDat.Stop();
                TimeSpan totalNodeFolderDatTime = totalNodeFolderDat.Elapsed;
                Console.WriteLine(string.Format("{0}个节点调度总耗时:{1}秒", nodes.Length, totalNodeFolderDatTime.TotalMilliseconds / 1000));
                HookHelper.Log += string.Format("{0}个节点调度总耗时:{1}秒", nodes.Length, totalNodeFolderDatTime.TotalMilliseconds / 1000) + DateTime.Now + ";\r\n";

                if (!HookHelper.isCloseCMD)
                {
                    Console.Read();
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
                //打印日志
                string log = HookHelper.Log + ex;
                WriteLog.WriteLogMethod(log);
                Environment.Exit(0);
                //throw;
            }
            //CSVLog
            if (HookHelper.useCSVLOG.Equals("true"))
            {
                CSVFile.SaveCSV(CSVData.GetDataTable(), path);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //!!删除指定目录下的所有的txt文件日志文件
            WriteLog.DeleteLog();

            //! 1.根据命令行中的值,初始化hook
            //! 1、解析参数,更新初始值
            argsPrase(args);

            //! 2、初始化数据库链接信息
            ClientConn.PraseDataBaseConfig(!HookHelper.method.Equals("wata")); //解析配置文件,并建立数据库连接。
            ClientConn.PraseTableTypeConfig();                                 //解析数据库对应要解析的表类型链接
            ClientConn.PraseComputerTableConfig();

            //!3、 初始化与数据库相关的hookhelper变量
            InitHookHelper(args);


            //CSVLog
            string serverIP = Program.GetLocalIP(HookHelper.serachIP);
            string hostName = Dns.GetHostName();
            string path     = ConfigurationManager.AppSettings["CSVLogPath"].ToString()
                              + "\\" + hostName.ToString() + "_" + serverIP.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";

            if (HookHelper.useCSVLOG.Equals("true"))
            {
                CSVData.CSVInit(path);
            }


            //! 为了后续计算速度快,提前从数据库中读取unit单元信息和模型路径信息,
            if (HookHelper.method.Equals("wata"))
            {
                ClientConn.PraseGridUnitConfigAllChina(HookHelper.computerNode);
            }
            else
            {
                ClientConn.PraseGridUnitConfig();
            }


            // 每个省对应一个数据库连接,每个连接里包含了降雨切片目录
            Dictionary <string, Dictionary <string, string> >    dbValues       = ClientConn.m_dbTableTypes;
            Dictionary <string, Dictionary <string, DataTable> > dbTableConfigs = ClientConn.m_dbTableConfig;

            //testEXEListening();

            try
            {
                if (HookHelper.method == "province")
                {
                    CalcOneByOne.runBySingleCC();
                    //执行插入日志
                    WriteLog.WriteLogMethod(HookHelper.Log, "runByCCFolder");
                }

                if (HookHelper.method == "wata")
                {
                    WriteUnitInfo.GetAllHsfxUnitTableByWATA();


                    CalcOneByOneWata.runBySingleCC();
                    //执行插入日志
                    WriteLog.WriteLogMethod(HookHelper.Log, "runByCCFolder");
                }

                //! 阻塞程序不关闭
                Console.WriteLine(string.Format("当前主机节点{0}网格计算调度完成  ", HookHelper.computerNode) + DateTime.Now);

                //执行插入日志
                WriteLog.WriteLogMethod(HookHelper.Log);

                if (!HookHelper.isCloseCMD)
                {
                    Console.Read();
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
                //打印日志
                string log = HookHelper.Log + ex;
                WriteLog.WriteLogMethod(log);
                Environment.Exit(0);
                //throw;
            }
            //CSVLog
            if (HookHelper.useCSVLOG.Equals("true"))
            {
                CSVFile.SaveCSV(CSVData.GetDataTable(), path);
            }
        }