/// <summary> /// Creates an moniker in a flowmMap /// </summary> /// <param name="writer">XmlWriter where the Moniker must be written to</param> /// <param name="toActivity">The activity that the floMap flows to</param> private static void WriteMoniker(XmlWriter writer, Activity toActivity) { try { if (toActivity.Guid == null) return; writer.WriteStartElement(String.Format(@"{0}Moniker", ActTypes.Where(at => at.Id == toActivity.ActivityInd).Select(at => at.Type).SingleOrDefault())); WriteAttribute(writer, "Id", XmlConvert.ToString(toActivity.Guid.Value)); writer.WriteEndElement(); //Moniker } catch (Exception ex) { MessageBox.Show(String.Format(@"Unable to write moniker {1}: {0}", ex.Message, toActivity.Guid)); } }
/// <summary> /// Writes an activity in xml format /// </summary> /// <param name="writer">Xml writer where the activity must be written to</param> /// <param name="activity">The activity that must be written to xml</param> private void WriteActivity(XmlWriter writer, Activity activity) { try { writer.WriteStartElement("BTProcessHasBTActivity"); var newGuid = Guid.NewGuid(); WriteAttribute(writer, "Id", XmlConvert.ToString(newGuid)); //Activity Type writer.WriteStartElement(ActTypes.Where(at => at.Id == activity.ActivityInd).Select(at => at.Type).SingleOrDefault()); WriteAttribute(writer, "Id", XmlConvert.ToString(activity.Guid.Value)); WriteAttribute(writer, "name", activity.ActivityName); WriteAttribute(writer, "isMenuItem", XmlConvert.ToString(activity.IsMenuItem)); writer.WriteStartElement("targetBTActs"); //Check if the Moniker set will be valid var flowmaps = from fm in _flowMaps join ta in _activities on fm.ToActivity equals ta.ActivityID where fm.FromActivity == activity.ActivityID && _activities.Contains(ta) select fm; foreach (var flowMap in flowmaps) WriteFlowMap(writer, flowMap, activity.ActivityInd); writer.WriteEndElement(); //targetBTActs writer.WriteEndElement(); //Activity Type writer.WriteEndElement(); //BTProcessHasBTActivity } catch (Exception ex) { MessageBox.Show(String.Format(@"Unable to write activity {1}: {0}", ex.Message, activity.ActivityName)); } }