예제 #1
0
        public FileUploader(UserFile file)
        {
            _file = file;

            _dataLength = _file.FileStream.Length;
            _dataSent = 0;

            _client = Utils.CreateServiceClient(); //new MixObjectsSoapClient("", "http://localhost/services/MixObjects.asmx");
            //事件绑定
            _client.StoreFileAdvancedCompleted += new EventHandler<StoreFileAdvancedCompletedEventArgs>(_client_StoreFileAdvancedCompleted);
            _client.CancelUploadCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(_client_CancelUploadCompleted);
            _client.ChannelFactory.Closed += new EventHandler(ChannelFactory_Closed);
        }
예제 #2
0
        public FileUploader(UserFile file)
        {
            _file = file;

            _dataLength = _file.FileStream.Length;
            _dataSent   = 0;

            _client = Utils.CreateServiceClient(); //new MixObjectsSoapClient("", "http://localhost/services/MixObjects.asmx");
            //事件绑定
            _client.StoreFileAdvancedCompleted += new EventHandler <StoreFileAdvancedCompletedEventArgs>(_client_StoreFileAdvancedCompleted);
            _client.CancelUploadCompleted      += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(_client_CancelUploadCompleted);
            _client.ChannelFactory.Closed      += new EventHandler(ChannelFactory_Closed);
        }
예제 #3
0
        /// <summary>
        /// 加载配置参数
        /// </summary>
        /// <param name="initParams"></param>
        private void LoadConfiguration(IDictionary <string, string> initParams)
        {
            string tryTest = string.Empty;

            //加载定制配置信息串
            _customParams = initParams["forumid"];

            if (initParams.ContainsKey("MaxUploads") && !string.IsNullOrEmpty(initParams["MaxUploads"]))
            {
                int.TryParse(initParams["MaxUploads"], out _maxUpload);
            }

            if (initParams.ContainsKey("MaxFileSizeKB") && !string.IsNullOrEmpty(initParams["MaxFileSizeKB"]))
            {
                if (int.TryParse(initParams["MaxFileSizeKB"], out _maxFileSize))
                {
                    _maxFileSize = _maxFileSize * 1024;
                }
            }

            if (initParams.ContainsKey("FileFilter") && !string.IsNullOrEmpty(initParams["FileFilter"]))
            {
                _fileFilter = initParams["FileFilter"];
            }

            if (initParams.ContainsKey("forumid") && !string.IsNullOrEmpty(initParams["forumid"]))
            {
                _forumid = Utils.StrToInt(initParams["forumid"], 0);
            }

            if (initParams.ContainsKey("max") && !string.IsNullOrEmpty(initParams["max"]))
            {
                _maxAttachments = Utils.StrToInt(initParams["max"], 0);
            }

            CredentialInfo _creInfo = Utils.GetCredentialInfo();

            if (_creInfo.UserID <= 0)
            {
                ShowMessageBox("您未登陆系统");
                SetUploadButton(false);
                return;
            }
            else
            {
                MixObjectsSoapClient _client = Utils.CreateServiceClient();
                _client.GetAttachmentUploadSetCompleted += new EventHandler <GetAttachmentUploadSetCompletedEventArgs>(_client_GetAttachmentUploadSetCompleted);
                _client.GetAttachmentUploadSetAsync(_creInfo, _forumid);
            }
        }