private string CreatetImportValueFile() { IList <CustomPropertyValue> valueList = new List <CustomPropertyValue>(); Assembly assm = System.Reflection.Assembly.GetAssembly(this.GetType()); using (StreamReader reader = new StreamReader(assm.GetManifestResourceStream("PJOResourceMgmt.CustomPropertyTargets.csv"))) { string line = null; while ((line = reader.ReadLine()) != null) { CustomPropertyValue info = new CustomPropertyValue(); string[] lines = line.Split(','); info.IdName = lines[0]; info.GraduateDate = DateTime.Now.AddYears(rnd.Next(birthPlance.Count - 1) * 5).ToString("yyyy/MM/dd hh:MM:ss"); info.BirthPlace = birthPlance[rnd.Next(birthPlance.Count - 1)]; valueList.Add(info); } } string json = JsonConvert.SerializeObject(valueList); string fileName = @".\importValue" + DateTime.Now.ToString("yyyyyMMddhhmmss") + ".json"; // これでやるとプロセスが排他で開いている状態になっている。 //System.IO.File.Create(fileName); //using (StreamWriter writer = new StreamWriter(fileName)) //{ // writer.Write(json); //} System.IO.File.WriteAllText(fileName, json); return(fileName); }
public ProductStoreSearchCriteria Clone() { ProductStoreSearchCriteria result = new ProductStoreSearchCriteria(); result.CategoryId = this.CategoryId; foreach (CustomPropertyValue cpv in this.CustomProperties) { CustomPropertyValue cp = cpv.Clone(); result.CustomProperties.Add(cp); } result.Keyword = this.Keyword; result.ManufacturerId = this.ManufacturerId; result.MaxPrice = this.MaxPrice; result.MinPrice = this.MinPrice; result.SortBy = this.SortBy; result.SortOrder = this.SortOrder; result.VendorId = this.VendorId; return(result); }
/// <summary> /// Returns a single JIRA issue by its KEY. Includes all fields and child collections (e.g. comments) /// </summary> /// <param name="issueKey">The JIRA issue key</param> /// <param name="jiraCreateMetaData">The creation meta-data</param> /// <returns>The JIRA issue object</returns> public JiraIssue GetIssueByKey(string issueKey, JiraCreateMetaData jiraCreateMetaData) { string result = RunQuery(resource: JiraResource.issue, argument: issueKey, method: "GET"); LogTraceEvent(this.eventLog, result, EventLogEntryType.SuccessAudit); //First deserialize into a generic JObject; JObject jIssue = JObject.Parse(result); //For the standard fields we use the standard deserializer JiraIssue issue = jIssue.ToObject <JiraIssue>(); //We need to get a handle on the fields meta-data for use later JObject jIssueTypeFields = null; if (jiraCreateMetaData != null) { JiraProject project = jiraCreateMetaData.Projects.FirstOrDefault(p => p.Id == issue.Fields.Project.Id); if (project != null) { IssueType issueType = project.IssueTypes.FirstOrDefault(t => t.Id == issue.Fields.IssueType.Id); if (issueType != null) { //See if we are missing any required properties jIssueTypeFields = issueType.Fields; } } } //Now we need to get the custom fields from the JObject directly JObject jFields = (JObject)jIssue["fields"]; if (jFields != null) { foreach (JProperty jProperty in jFields.Properties()) { //Make sure it's a custom field if (jProperty.Name.StartsWith(JiraCustomFieldValue.CUSTOM_FIELD_PREFIX)) { JiraCustomFieldValue customFieldValue = new JiraCustomFieldValue(jProperty.Name); CustomPropertyValue cpv = new CustomPropertyValue(); //We need to try and match the type of value if (jProperty.Value != null && jProperty.Value.Type != JTokenType.None && jProperty.Value.Type != JTokenType.Null) { LogTraceEvent(eventLog, String.Format("Found custom field '{0}' of JProperty type " + jProperty.Value.Type, jProperty.Name), EventLogEntryType.Information); if (jProperty.Value.Type == JTokenType.Array && jProperty.Value is JArray) { //Iterate through the list of values List <string> listOptionValueNames = new List <string>(); JArray jOptions = (JArray)jProperty.Value; foreach (JToken jToken in jOptions) { if (jToken is JObject) { JObject jOption = (JObject)jToken; //If we have an object that has an ID property then we have a multi-list if (jOption["id"] != null && jOption["id"].Type == JTokenType.String) { LogTraceEvent(eventLog, String.Format("Found custom field '{0}' that is an array of objects with ID field ({1})", jProperty.Name, jOption["id"].Type), EventLogEntryType.Information); string id = (string)jOption["id"]; if (!String.IsNullOrEmpty(id)) { //Need to convert into an integer and set the list value int idAsInt; if (Int32.TryParse(id, out idAsInt)) { LogTraceEvent(eventLog, String.Format("Looking for custom field value name that matches custom field {0} option value id {1}", jProperty.Name, idAsInt), EventLogEntryType.Information); string optionName = LookupCustomFieldOptionName(idAsInt, jIssueTypeFields, customFieldValue.CustomFieldName); listOptionValueNames.Add(optionName); LogTraceEvent(eventLog, String.Format("Found JIRA custom field {2} value name that matches custom field {0} option value id {1}", jProperty.Name, idAsInt, optionName), EventLogEntryType.Information); } } } } } if (listOptionValueNames.Count > 0) { cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.MultiList; cpv.MultiListValue = listOptionValueNames; } } else if (jProperty.Value.Type == JTokenType.Object) { //If we have an object that has an ID property then we have a single-list //If we have a 'name' property then we have a user field if (jProperty.Value is JObject) { JObject jOption = (JObject)jProperty.Value; if (jOption["id"] != null && jOption["id"].Type == JTokenType.String) { LogTraceEvent(eventLog, String.Format("Found custom field '{0}' that is an object with ID field ({1})", jProperty.Name, jOption["id"].Type), EventLogEntryType.Information); string id = (string)jOption["id"]; if (!String.IsNullOrEmpty(id)) { //Need to convert into an integer and get the name from the meta-data int idAsInt; if (Int32.TryParse(id, out idAsInt)) { LogTraceEvent(eventLog, String.Format("Looking for custom field value name that matches custom field {0} option value id {1}", jProperty.Name, idAsInt), EventLogEntryType.Information); string optionName = LookupCustomFieldOptionName(idAsInt, jIssueTypeFields, customFieldValue.CustomFieldName); cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.List; cpv.StringValue = optionName; LogTraceEvent(eventLog, String.Format("Found JIRA custom field {2} value name that matches custom field {0} option value id {1}", jProperty.Name, idAsInt, optionName), EventLogEntryType.Information); } } } else if (jOption["name"] != null && jOption["name"].Type == JTokenType.String) { LogTraceEvent(eventLog, String.Format("Found custom field '{0}' that is an object with NAME field ({1})", jProperty.Name, jOption["name"].Type), EventLogEntryType.Information); string username = (string)jOption["name"]; if (!String.IsNullOrEmpty(username)) { cpv.StringValue = username; cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.User; } } } } else if (jProperty.Value.Type == JTokenType.Boolean) { //Simple integer property cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.Boolean; cpv.BooleanValue = (bool?)jProperty.Value; } else if (jProperty.Value.Type == JTokenType.Integer) { //Simple integer property cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.Integer; cpv.IntegerValue = (int?)jProperty.Value; } else if (jProperty.Value.Type == JTokenType.Float) { //Simple float property cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.Decimal; cpv.DecimalValue = (decimal?)((float?)jProperty.Value); } else if (jProperty.Value.Type == JTokenType.Date) { //Simple date/time property cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.Date; cpv.DateTimeValue = (DateTime?)jProperty.Value; } else if (jProperty.Value.Type == JTokenType.String) { //Simple string property cpv.CustomPropertyType = CustomPropertyValue.CustomPropertyTypeEnum.Text; cpv.StringValue = (string)jProperty.Value; } } customFieldValue.Value = cpv; issue.CustomFieldValues.Add(customFieldValue); } } } return(issue); }
public CustomPropertyValue Clone() { CustomPropertyValue result = new CustomPropertyValue(this.PropertyBvin, this.PropertyValue); return result; }
public CustomPropertyValue Clone() { CustomPropertyValue result = new CustomPropertyValue(this.PropertyBvin, this.PropertyValue); return(result); }
public CustomPropertyAttribute(CustomPropertyValue value) : base("Custom", value.ToString()) { }
public CustomPropertyValue Clone() { var result = new CustomPropertyValue(PropertyBvin, PropertyValue); return(result); }