public StoreQuery GenerateQuery() { ErrorLog.Clear(); Validate(); if (ValidationResults.Any()) { return(null); } var subQueries = new List <StoreQuery>(); try { for (int i = 1; i < SubQueryList.Count; i++) { var q = SubQueryList[i]; var gen = _engine.GenerateQuery(q); subQueries.Add(gen); } var result = _engine.GenerateQuery(MainQuery, StoreParameters); result.Query.SubQueries = subQueries.ToDictionary(s => s.Name, s => s.Query); return(result); } catch (Exception exc) { ErrorLog.AppendLine($"Cannot generate query: {exc.Message}"); return(null); } }
/// <summary> /// Adds the <see cref="Attachments"/> to the <see cref="Issue"/>. /// </summary> protected void AddAttachmentsToIssue() { if (Attachments.Count == 0) { return; } SetStatus("Preparing the list of attachments"); foreach (KeyValuePair <string, byte[]> pair in Attachments) { try { // Due to an error in WSDL, convert the data to s-bytes from bytes SetStatus(string.Format("Adding attachments — {0} — {1}", pair.Key, "Copying")); sbyte[] datatemp = new sbyte[pair.Value.Length]; for (int a = 0; a < pair.Value.Length; a++) { datatemp[a] = unchecked ((sbyte)pair.Value[a]); } SetStatus(string.Format("Adding attachments — {0} — {1}", pair.Key, "Sending")); Project.Server.Service.addAttachmentsToIssue(Project.Server.GetSignInToken(), Issue.key, new string[] { pair.Key }, datatemp); } catch (Exception ex) { ErrorLog.AppendFormat("Could not add the “{0}” attachment to the issue. {1}", pair.Key, ex.Message); ErrorLog.AppendLine(); } } }
/// <summary> /// In case JIRA rejects some of the issue params at the creation time, set them one-by-one /// Uses the <see cref="Project"/> for project and JIRA server, and <see cref="Issue"/> for the issue-key to update. /// </summary> protected void Submit_Run_UpdateIssue() { SetStatus("Preparing fields for the issue update"); List <RemoteFieldValue> arValues = new List <RemoteFieldValue>(); // Generic fields if (Component != null) { arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.components, Component.JiraId)); } if (Priority != null) { arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.priority, Priority.JiraId)); } //arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.reporter, Project.Server.Username)); arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.type, IssueType.JiraId)); arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.summary, Title)); arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.description, Body)); if (Status != null) { arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.status, Status.JiraId)); } arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.assignee, Assignee)); // Custom fields UpdateIssue_SetCustomFields(arValues); // Submit the values to the server SetStatus("Updating issue fields"); foreach (RemoteFieldValue value in arValues) { try { SetStatus("Updating issue fields — " + value.id); Project.Server.Service.updateIssue(Project.Server.GetSignInToken(), Issue.key, new RemoteFieldValue[] { value }); } catch (Exception ex) { ErrorLog.AppendFormat("Could not set the “{0}” field on the issue. {1}", value.id, ex.Message); ErrorLog.AppendLine(); } } // Dirty hack: try opening the issue if (Status.Name == "Open") { try { SetStatus("Updating issue fields — Opening issue"); Project.Server.Service.progressWorkflowAction(Project.Server.GetSignInToken(), Issue.key, "Open", new RemoteFieldValue[] {}); } catch (Exception ex) { ErrorLog.AppendFormat("Could not open the issue. {0}", ex.Message); ErrorLog.AppendLine(); } } }
/// <summary> /// 把一行数据转换成一个对象,每一列是一个属性 /// </summary> private Dictionary <string, object> ConvertRowToDict(DataTable _dt, DataRow row, int firstDataRow, string _fileName, int _idx = 0) { var rowData = new Dictionary <string, object>(); foreach (DataColumn column in _dt.Columns) { object value = row[column]; if (value.GetType() == typeof(DBNull)) { value = "NULL"; // GetColumnDefault(_dt, column, firstDataRow); ErrorLog.AppendLine("文件:" + _fileName + " 表: " + _dt.TableName + " : 第" + (int.Parse(column.ColumnName.Replace("Column", "")) + 1) + "列 第" + (_idx + 1) + "行空"); } else if (firstDataRow > 1) { value = value.ToString(); //try //{ // switch (_dt.Rows[1][column]) // { // case "int": // if (value.GetType() == typeof(double)) // { // 去掉数值字段的“.0” // double num = (double)value; // if ((int)num == num) // value = (int)num; // } // else // value = int.Parse(value.ToString()); // break; // case "float": // value = float.Parse(value.ToString()); // break; // case "double": // value = double.Parse(value.ToString()); // break; // default: // value = value.ToString(); // break; // } //} //catch (FormatException) //{ // // throw new FormatException("has not correct format"); // value = value.ToString(); //} } // 表头自动转换成小写 //if (lowcase) // fieldName = fieldName.ToLower(); string fieldName = _dt.Rows[0][column].ToString(); rowData[fieldName] = value; } return(rowData); }
/// <summary> /// Adds one single custom field for the <see cref="UpdateIssue_SetCustomFields"/> function. /// </summary> protected void UpdateIssue_SetCustomFields_Add(List <RemoteFieldValue> arValues, Dictionary <string, string> mapFieldNameToId, string sFieldName, string sFieldValue) { if (string.IsNullOrEmpty(sFieldName)) { return; } if (string.IsNullOrEmpty(sFieldValue)) { return; } // Lookup ID by the name string sFieldId; if (!mapFieldNameToId.TryGetValue(sFieldName, out sFieldId)) { ErrorLog.AppendFormat("Could not find a custom field named “{0}” on the “{1}” JIRA server.", sFieldName, Project.Server.Name); ErrorLog.AppendLine(); return; } // Add to the submit-list arValues.Add(CreateFieldValue(sFieldId, sFieldValue)); }