public static bool LoadDamInfo()
        {
            List <Dam> dams = DAMCommon.GetDamConfig();

            foreach (Dam dam in dams)
            {
                DAMCommon.SetDamDetail(dam);
            }

            if (DAMCommon.CommonDamDetails.Count == 0)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public static void UploadERMFile()
        {
            UploadERMFileProcess();
            if (_UploadingTaskList.Count > _MaxThreadCount)
            {
                return;
            }
            //read xml, get dam

            //get reg status
            //load xml, read dam
            List <Dam> dams = DAMCommon.GetDamConfig();

            foreach (Dam dam in dams)
            {
                DAMCommon.SetDamDetail(dam);
            }

            if (DAMCommon.CommonDamDetails.Count == 0)
            {
                System.Threading.Monitor.Enter(_UploadingIDs);
                _UploadingIDs.Clear();
                System.Threading.Monitor.Exit(_UploadingIDs);

                System.Threading.Monitor.Enter(_UploadingTaskList);
                _UploadingTaskList.Clear();
                System.Threading.Monitor.Exit(_UploadingTaskList);
                return;
            }

            string scrInfo = Utilities.GetProcessID();

            _logger.Debug("scrInfo:" + scrInfo);
            try
            {
                foreach (DamDetail dam in DAMCommon.CommonDamDetails)
                {
                    //get task
                    using (var client = new HttpClient())
                    {
                        var parameters = String.Format("/api/v1/upload/uploadtasks/{0}", scrInfo);
                        _logger.Debug("url:" + dam.WebApiurl + parameters);
                        HttpResponseMessage response = client.GetAsync(dam.WebApiurl + parameters).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            var result = response.Content.ReadAsAsync <List <UploadFileTaskWorkDto> >().Result;
                            foreach (UploadFileTaskWorkDto uploadFileTaskWorkDto in result)
                            {
                                UploadTask uploadTask = new UploadTask();
                                uploadTask.UniqueID = uploadFileTaskWorkDto.UniqueID;
                                uploadTask.UploadFileTaskWorkDto = uploadFileTaskWorkDto;
                                uploadTask.Dam = dam;
                                System.Threading.Monitor.Enter(_UploadingTaskList);
                                if (_UploadingTaskList.Where(t => t.UniqueID == uploadFileTaskWorkDto.UniqueID).FirstOrDefault() == null)
                                {
                                    _UploadingTaskList.Add(uploadTask);
                                    _logger.Debug("new task:" + uploadFileTaskWorkDto.UniqueID);
                                }
                                System.Threading.Monitor.Exit(_UploadingTaskList);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Threading.Monitor.Enter(_UploadingIDs);
                _UploadingIDs.Clear();
                System.Threading.Monitor.Exit(_UploadingIDs);

                System.Threading.Monitor.Enter(_UploadingTaskList);
                _UploadingTaskList.Clear();
                System.Threading.Monitor.Exit(_UploadingTaskList);
                _logger.Error("UploadERMFile error:" + ex.ToString());
            }
        }