public FtpFile(FtpFile cln, int taksId) { this.statistics.conType = ConnectionType.FtpFile; this.ftpUri = cln.ftpUri; this.ftpUsername = cln.ftpUsername; this.ftpPass = cln.ftpPass; this.ftpPort = cln.ftpPort; this.isPassive = cln.isPassive; this.ftpTimeout = cln.ftpTimeout; this.ftpUseBinary = cln.ftpUseBinary; this.ftpKeepAlive = cln.ftpKeepAlive; this.ftpProxyType = cln.ftpProxyType; this.filePath = cln.filePath; this.source_dest = cln.source_dest; this.addStrategy = new AddStrategyClass(cln.addStrategy); this.errorCount = cln.errorCount; this.sleepBeforeNext = cln.sleepBeforeNext; }
/// <summary> /// Парсинг XML-файла /// </summary> /// <returns> </returns> public PlannerText(string _plannerPath, ControllerOfOutput _outputs, LogOfSuccession _los) { this.outputs = _outputs; this.los = _los; this.BackupPlannerXml(); PlannerTask tmpTask = new PlannerTask(); FtpFile tmpFtpFile = new FtpFile(); WinFSFile tmpWinFSFile = new WinFSFile(); FileSupertype tmpFileSupertype = tmpFtpFile; AddStrategyClass tmpStrategy = new AddStrategyClass(); CmdRoute tmpCmdRoute = new CmdRoute(); ActionType source_dest = ActionType.Source; PrivateData pd = PrivateData.Instance; string nodeName = String.Empty; XmlTextReader reader = new XmlTextReader(_plannerPath); while (reader.Read()) { string readerValPriv = pd.GetValueFromTemplate(reader.Value); switch (reader.NodeType) { case XmlNodeType.Element: // Узел является элементом. nodeName = reader.Name; switch (nodeName) { case "task": tmpTask = new PlannerTask(); this.tasks.Add(tmpTask); break; case "route": tmpCmdRoute = new CmdRoute(); tmpTask.taskRouts.Add(tmpCmdRoute); break; case "sourceFile": source_dest = ActionType.Source; break; case "destinationFile": source_dest = ActionType.Destination; break; } break; //ToDo: добавить отлавливание оршибок при ошибочном преобразовании case XmlNodeType.Text: // Вывести текст в каждом элементе. switch (nodeName) { //исключительно Planner case "proxyAddress": this.prx.address = readerValPriv; break; case "proxyUser": this.prx.user = readerValPriv; break; case "proxyPass": this.prx.pass = readerValPriv; break; case "proxyAddressesToBypass": this.prx.addressesToBypas = readerValPriv; break; //пошли задания case "id": tmpTask.id = int.Parse(readerValPriv); break; case "isFake": tmpTask.isFake = bool.Parse(readerValPriv); break; case "taskDiscription": tmpTask.taskDiscription = readerValPriv; break; case "deleteTmp": tmpTask.deleteTmp = bool.Parse(readerValPriv); break; case "taskPeriod": tmpTask.period = readerValPriv; break; //добавление IP route'ов case "routeDestination": tmpCmdRoute.destination = readerValPriv; break; case "routeSubnetmask": tmpCmdRoute.subnetMask = readerValPriv; break; case "routeGateway": tmpCmdRoute.gateway = readerValPriv; break; //стратегия добавления case "addStrategyUseMask": tmpStrategy.usemask = bool.Parse(readerValPriv); break; case "addStrategyFileMask": tmpStrategy.fileMask = readerValPriv; break; case "addStrategyFileNameUsage": tmpStrategy.fileNameUsage = readerValPriv; break; case "addStrategyWorkInterval": tmpStrategy.workInterval = GlobalUtils.ParseWorkIntervalEnum(readerValPriv); break; case "addStrategyCheckDateCondition": tmpStrategy.checkDateCondition = readerValPriv; break; case "addStrategyUseCreationDate": tmpStrategy.useCreationDate = bool.Parse(readerValPriv); break; case "addStrategyDateRange": tmpStrategy.dateRange = GlobalUtils.ParseDateRangeEnum(readerValPriv); break; //пошли файлы-источники и файлы-назначения case "type": if (readerValPriv == "FTP") { tmpFtpFile = new FtpFile(tmpFtpFile, tmpTask.id); tmpFileSupertype = tmpFtpFile; tmpTask.uploadDownload.Add(tmpFileSupertype); } else { tmpWinFSFile = new WinFSFile(tmpWinFSFile, tmpTask.id); tmpFileSupertype = tmpWinFSFile; tmpTask.uploadDownload.Add(tmpFileSupertype); } tmpStrategy = new AddStrategyClass(tmpStrategy); tmpFileSupertype.addStrategy = tmpStrategy; tmpFileSupertype.source_dest = source_dest; break; case "ftpUsername": tmpFtpFile.ftpUsername = readerValPriv; break; case "ftpPass": tmpFtpFile.ftpPass = readerValPriv; break; case "ftpUri": tmpFtpFile.ftpUri = readerValPriv; break; case "ftpPort": tmpFtpFile.ftpPort = int.Parse(readerValPriv); break; case "isPassive": tmpFtpFile.isPassive = bool.Parse(readerValPriv); break; case "ftpTimeout": tmpFtpFile.ftpTimeout = int.Parse(readerValPriv); break; case "ftpUseBinary": tmpFtpFile.ftpUseBinary = bool.Parse(readerValPriv); break; case "ftpKeepAlive": tmpFtpFile.ftpKeepAlive = bool.Parse(readerValPriv); break; case "ftpProxyType": tmpFtpFile.ftpProxyType = readerValPriv; break; case "filePath": tmpFileSupertype.filePath = readerValPriv; break; case "maxErrorCout": tmpFileSupertype.errorCount = int.Parse(readerValPriv); break; case "sleepAfterError": tmpFileSupertype.sleepBeforeNext = int.Parse(readerValPriv); break; default: break; } break; case XmlNodeType.EndElement: /* * switch (reader.Name) * { * case "route": * tmpTask.taskRouts.Add(tmpCmdRoute); * break; * }*/ break; } } reader.Close(); }