Example #1
0
        void ProcessDownloads()
        {
            List <string> files = null;

            lock (m_pendingDownloads)
                if (m_pendingDownloads.Count > 0)
                {
                    files = m_pendingDownloads.ToList();
                    m_pendingDownloads.Clear();
                }

            if (files != null)
            {
                string localDlgFolder = AppPaths.DialogFolderPath;
                string cxnReqFile     = Names.ConnectionReqFile;
                var    netEngin       = new NetEngin(AppContext.Settings.NetworkSettings);

                for (int i = files.Count - 1; i >= 0; --i)
                {
                    string fileName = files[i];
                    string destPath = Path.Combine(localDlgFolder, fileName);
                    string srcURL   = Urls.DialogDirURL + fileName;


                    try
                    {
                        netEngin.Download(destPath, srcURL);
                    }
                    catch (Exception ex)
                    {
                        AppContext.LogManager.LogSysError("Traitement des transferts à partir du serveur: " +
                                                          ex.Message, true);
                        continue;
                    }

                    if (string.Compare(fileName, cxnReqFile, true) == 0)
                    {
                        try
                        {
                            ProcessConnectionReq(DialogEngin.ReadConnectionsReq(AppPaths.ConnectionReqPath));
                        }
                        catch (Exception ex)
                        {
                            TextLogger.Warning(ex.Message);
                        }
                    }
                    else
                    {
                        uint clID = uint.Parse(Path.GetFileNameWithoutExtension(fileName),
                                               System.Globalization.NumberStyles.AllowHexSpecifier);

                        try
                        {
                            ProcessDialog(clID, DialogEngin.ReadHubDialog(Path.Combine(localDlgFolder, fileName), clID));
                        }
                        catch (Exception ex)
                        {
                            AppContext.LogManager.LogSysError("Traitement des transferts à partir du serveur: " +
                                                              ex.Message, true);
                            continue;
                        }
                    }

                    files.RemoveAt(i);
                }


                foreach (string file in files)
                {
                    AddDownload(file);
                }
            }

            //allways need to be downlaoded
            AddDownload(Names.ConnectionReqFile);
        }