Exemple #1
0
        void LoadDataForm_onGetFileListSuccessfully(HTTPAgent.FileType type, FileList fileList)
        {
            if (fileList != null && fileList.Description != null)
            {
                for (int i = fileList.Description.Count - 1; i >= 0; i--)
                {
                    switch (type)
                    {
                        case HTTPAgent.FileType.channelSetting:
                            DataCenter.Instance().ChannelSettingDescriptions[fileList.Description[i].ID] = fileList.Description[i];
                            break;

                        case HTTPAgent.FileType.equipmentParameter:
                            DataCenter.Instance().EquipmentParameterDescriptions[fileList.Description[i].ID] = fileList.Description[i];
                            break;

                        case HTTPAgent.FileType.linkconfiguration:
                            DataCenter.Instance().LinkConfigurationDescriptions[fileList.Description[i].ID] = fileList.Description[i];
                            break;

                        case HTTPAgent.FileType.emi:
                            DataCenter.Instance().EMIDescriptions[fileList.Description[i].ID] = fileList.Description[i];
                            break;
                    }

                    if (type != HTTPAgent.FileType.emi)
                    {
                        mTaskStack.Push(new Task(TaskType.getFile, type, fileList.Description[i].ID, fileList.Description[i].Title));
                    }
                }
            }

            ExecuteTask();
        }
Exemple #2
0
        public void getFileList(Form attachedForm, FileType type)
        {
            new Thread(delegate()
            {
                byte[] respData;
                string json = "";
                WebHeaderCollection headers;
                string url = getUrl(Action.getfilelist) + "/" + type.ToString().ToLower();
                HttpStatusCode statusCode = HTTPRequest.MakeRequest(url, "GET",
                    Constants.JSON_MIME, null,
                    null, out respData, out headers);
                if (statusCode == HttpStatusCode.OK)
                {
                    if (onGetFileListSuccessfully != null)
                    {
                        FileList fileList = new FileList();
                        if (respData != null)
                        {
                            json = Encoding.UTF8.GetString(respData);
                            fileList = Utility.JsonDeserialize<FileList>(json);
                            Utility.FillFileList(fileList);
                        }
                        attachedForm.BeginInvoke(onGetFileListSuccessfully, type, fileList);
                    }
                }
                else
                {
                    if (onGetFileListFailed != null)
                        attachedForm.BeginInvoke(onGetFileListFailed, type, statusCode);
                }

            }).Start();
        }