コード例 #1
0
ファイル: User.cs プロジェクト: ssc1223/piCite
 private void fileCompletedHandler(object sender, EventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start(localPhysicalPath);
         if (MasterControl != null)
         {
             MasterControl.Invoke(MasterControl.delegateFileDownloaded, new Object[] { });
             MasterControl = null;
         }
     }
     catch (Exception ex)
     {
         this.log.WriteLine(LogType.Error, "User::fileCompletedHandler", ex.ToString());
     }
 }
コード例 #2
0
ファイル: MasterControlThread.cs プロジェクト: ssc1223/piCite
 public MasterControlThread(MasterControl master)
 {
     this.mastercontrol = master;
 }
コード例 #3
0
ファイル: User.cs プロジェクト: ssc1223/piCite
        public void DownloadFile(string strFileName, MasterControl mastercontrol, string strRequestURL)
        {
            try
            {
                MasterControl = mastercontrol;
                if (!System.IO.Directory.Exists(Properties.Settings.Default.DEFAULT_FILES_FOLDER))
                {
                    try
                    {
                        string strLocalFileStoragePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\πFolio";
                        System.IO.Directory.CreateDirectory(strLocalFileStoragePath);
                        Properties.Settings.Default.DEFAULT_FILES_FOLDER = strLocalFileStoragePath;
                        Properties.Settings.Default.Save();
                        localPhysicalPath = Properties.Settings.Default.DEFAULT_FILES_FOLDER + @"\" + Regex.Replace(strFileName, @"^\d+_\d+_|_$", string.Empty);
                    }
                    catch
                    {
                        if(strRequestURL == null)
                        {
                            localPhysicalPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + @"\" + Regex.Replace(strFileName, @"^\d+_\d+_|_$", string.Empty);
                        }
                        else
                        {
                            localPhysicalPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + @"\Templates\" + Regex.Replace(strFileName, @"^\d+_\d+_|_$", string.Empty);
                        }
                    }
                }
                else
                {
                    if (strRequestURL == null)
                    {
                        localPhysicalPath = Properties.Settings.Default.DEFAULT_FILES_FOLDER + @"\" + Regex.Replace(strFileName, @"^\d+_\d+_|_$", string.Empty);
                    }
                    else
                    {
                        localPhysicalPath = Properties.Settings.Default.DEFAULT_FILES_FOLDER + @"\Templates\" + Regex.Replace(strFileName, @"^\d+_\d+_|_$", string.Empty);

                    }
                }

                if (strRequestURL == null)
                {
                    strRequestURL = ServerAddress + Properties.Settings.Default.URI_LOCALDATASERVICE + "?op=PDF&from=" + DeviceTypes.MSWordWin.ToString() + "&authentication=" + Authentication + "&file=" + strFileName;
                }
                WebClient webClient = new WebClient();
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(fileCompletedHandler);
                webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
                webClient.DownloadFileAsync(new Uri(strRequestURL), localPhysicalPath);
            }
            catch(Exception ex)
            {
                this.log.WriteLine(LogType.Error, "User::DownloadFile", ex.ToString());
            }
        }