private void InitOperationAttributes(int operationId) { if (operationId == 0) { operationAttributes1.InitializeControl(null); return; } _viewShedulerStepModel.nameVis = cbOperation.Text; string fileName = OperationTools.GetOperationFileNameById(operationId); if (string.IsNullOrEmpty(fileName)) { operationAttributes1.InitializeControl(null); return; } Type attrType = null; string operName = OperationTools.GetOperationNameEnById(operationId); string operFileName = OperationTools.GetOperationFileNameById(operationId); string operFileMd5 = OperationTools.GetOperationFileMd5ById(operationId); if (!string.IsNullOrEmpty(operName) && !string.IsNullOrEmpty(operFileName) && !string.IsNullOrEmpty(operFileMd5)) { attrType = PluginOperationAdapter.GetPluginOperationAttributesType( operName , operFileName , operFileMd5); } if (attrType != null) { IOperationAttributes operationAttributesInstance = (IOperationAttributes)Activator.CreateInstance(attrType); //Ищем сохраненные атрибуты JObject savedModel = NewtonJson.GetModelFromJson(_viewShedulerStepModel.OperationAttributes) as JObject; JToken token = null; if (savedModel != null && savedModel.HasValues) { foreach (var prop in operationAttributesInstance.GetType().GetProperties()) { savedModel.TryGetValue(prop.Name, out token); if (token != null) { object propValue = ExtTools.ConvertStringToType(token.ToString(), prop.PropertyType); if (propValue != null) { prop.SetValue(operationAttributesInstance, propValue); } } } } operationAttributes1.InitializeControl(operationAttributesInstance, operationId); } else { operationAttributes1.InitializeControl(null); } }
protected override void ActExecution() { const string BAT_FILE_NAME = @"commands.bat"; const string CURL_EXE_FILE_NAME = @"curl.exe"; const string CURL_CRT_EXE_FILE_NAME = @"ca-bundle.crt"; const string DIRECTORY_NAME = "Curl"; const string FTP_HOST = @"mskftp.sela.ru"; const string LOGIN = "******"; const string PASSWORD = "******"; const string DESTINATION_DIRECTORY = @"C:\SystemUtils\Curl"; this._logText = new StringBuilder(); Log($"Download from FTP {CURL_EXE_FILE_NAME}"); if (!Directory.Exists(DESTINATION_DIRECTORY)) { Directory.CreateDirectory(DESTINATION_DIRECTORY); Log($"Directory {DESTINATION_DIRECTORY} was created"); } var batFileFullPath = Path.Combine(DESTINATION_DIRECTORY, BAT_FILE_NAME); var curlFullPath = Path.Combine(DESTINATION_DIRECTORY, CURL_EXE_FILE_NAME); var curlCrtFullPath = Path.Combine(DESTINATION_DIRECTORY, CURL_CRT_EXE_FILE_NAME); try { FtpWorks.DownloadFileFromFtp(DESTINATION_DIRECTORY, FTP_HOST, LOGIN, PASSWORD, DIRECTORY_NAME, BAT_FILE_NAME); FtpWorks.DownloadFileFromFtp(DESTINATION_DIRECTORY, FTP_HOST, LOGIN, PASSWORD, DIRECTORY_NAME, CURL_EXE_FILE_NAME); FtpWorks.DownloadFileFromFtp(DESTINATION_DIRECTORY, FTP_HOST, LOGIN, PASSWORD, DIRECTORY_NAME, CURL_CRT_EXE_FILE_NAME); } catch (Exception ex) { SendReportToDB($"Ошибка загрузки файлов по FTP:{Environment.NewLine}{ex.ToString()}{Environment.NewLine}{"Лог: "}{this._logText.ToString()}"); return; } Log($"Executing command..."); var executionResult = new List <string>(); try { //this._command = @"http://localhost:5984/dk_0_remote"; executionResult = ExecuteApplicationWithResult(curlFullPath, this._command); //var executionResult = ExecuteApplication(batFileFullPath, ""); Log($"Executing completed, code {executionResult}"); } catch (Exception ex) { SendReportToDB($"Ошибка выполнения команды:{Environment.NewLine}{ex.ToString()}{Environment.NewLine}{"Лог: "}{this._logText.ToString()}{Environment.NewLine}Console text: {string.Join(Environment.NewLine, executionResult.ToArray())}"); return; } //this._parameterName = "doc_count"; var resultText = string.Empty; if (string.IsNullOrEmpty(this._parameterName)) { resultText = $"{this._logText.ToString()}{Environment.NewLine}CouchDB COMMAND was successfully completed.{Environment.NewLine}{string.Join(Environment.NewLine, executionResult.ToArray())}"; } else { dynamic model = (dynamic)(NewtonJson.GetModelFromJson(string.Join(Environment.NewLine, executionResult.ToArray()))); resultText = (string)((Newtonsoft.Json.Linq.JObject)model).GetValue(this._parameterName); } Result = resultText; }