Exemplo n.º 1
0
 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());
     }
 }
Exemplo n.º 2
0
 public MasterControlThread(MasterControl master)
 {
     this.mastercontrol = master;
 }
Exemplo n.º 3
0
        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());
            }
        }