Beispiel #1
0
        public void ThreadMethod(object ParObject)
        {
            WorkInfo workInfo = ParObject as WorkInfo;

            workInfo = WorkConfig.GetInstance().GetWorkInfoByID(workInfo.id);
            if (workInfo != null)
            {
                ProcessDownImage processDown = new ProcessDownImage();
                foreach (RowColumns rc in workInfo.rcList)
                {
                    processDown.count = processDown.count + (rc.maxRow - rc.minRow + 1) * (rc.maxCol - rc.minCol + 1);
                }
                //if (workInfo.mapType == MapType.Tiandi)
                //{
                //    processDown.count = processDown.count;
                //}
                workInfo.processDownImage = processDown;
                int minZoom = 0;
                int maxZoom = 0;
                if (workInfo.rcList.Count > 0)
                {
                    minZoom = workInfo.rcList[0].zoom;
                    maxZoom = workInfo.rcList[0].zoom;
                }
                foreach (RowColumns rc in workInfo.rcList)
                {
                    if (minZoom > rc.zoom)
                    {
                        minZoom = rc.zoom;
                    }
                    if (maxZoom < rc.zoom)
                    {
                        maxZoom = rc.zoom;
                    }
                }
                workInfo.CreateTitle().CreateHtmlDemo(workInfo, minZoom, maxZoom);
                workInfo.CreateConfig();
                //FileTools.HtmlTool.CreateHtmlDemo(workInfo, minZoom, maxZoom);
                //if (workInfo.isAusterityFile)
                //{
                //    string austerityFilePath = Path.Combine(workInfo.filePath, "Layers");
                //    if (!Directory.Exists(austerityFilePath))
                //    {
                //        Directory.CreateDirectory(austerityFilePath);
                //    }
                //    workInfo.createAusterityConfig(austerityFilePath);
                //}
                var isMutilThread =
                    WorkConfig.GetInstance()
                    .Commandconfig.workInfoList.FirstOrDefault(
                        m => m.downStates == DownStates.start && m.id != workInfo.id) != null;
                foreach (RowColumns rc in workInfo.rcList)
                {
                    if (workInfo.downStates != DownStates.stop)
                    {
                        if (isMutilThread)
                        {
                            NewGetTiles(rc.minRow, rc.maxRow, rc.minCol, rc.maxCol, rc.zoom, workInfo);
                        }
                        else
                        {
                            Thread t = rc.GetData() as Thread;
                            if (t != null && t.ThreadState == ThreadState.Stopped)
                            {
                                t.Resume();
                            }
                            else
                            {
                                var result = System.Threading.ThreadPool.QueueUserWorkItem(
                                    new WaitCallback(
                                        o =>
                                {
                                    NewGetTiles(
                                        rc.minRow,
                                        rc.maxRow,
                                        rc.minCol,
                                        rc.maxCol,
                                        rc.zoom,
                                        workInfo);
                                }));
                                if (!result) // 加入线程池失败,则直接下载
                                {
                                    NewGetTiles(rc.minRow, rc.maxRow, rc.minCol, rc.maxCol, rc.zoom, workInfo);
                                }
                            }
                        }
                    }
                }
                if (workInfo.downStates == DownStates.start)
                {
                    workInfo.downStates = DownStates.ready;
                }
                else if (workInfo.downStates == DownStates.stop)
                {
                    if (this.DownImage != null)
                    {
                        this.DownImage(workInfo.id, 0, workInfo.processDownImage.count, 0, 0);
                    }
                }
                workInfo.WriteConfigurationToFile();
                lock (obj)
                {
                    WorkConfig.GetInstance().saveConfig();
                }
            }
        }