public static int Main(string [] args) { try { string dynTrnInitializerFile = "DynTrnInitializers.xml"; if (args != null && args.Length > 0) { dynTrnInitializerFile = args[0]; } else { if (!File.Exists(dynTrnInitializerFile)) { dynTrnInitializerFile = Path.Combine(GxContext.StaticPhysicalPath(), dynTrnInitializerFile); } } List <DynTrnInitializer> dataproviders = GXXmlSerializer.Deserialize <List <DynTrnInitializer> >(typeof(List <DynTrnInitializer>), File.ReadAllText(dynTrnInitializerFile), "Objects", string.Empty, out List <string> errors); GXDataInitialization dataInitilization = new GXDataInitialization(); int result = dataInitilization.ExecDataInitialization(dataproviders); if (result == 0) { File.Delete(dynTrnInitializerFile); } return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); GXLogging.Error(log, ex); return(1); } }
public virtual string ToXml(bool includeHeader, bool includeState, string rootName, string sNameSpace) { XmlAttributeOverrides ov = null; if (!includeState) { if (Count > 0) { ov = GXXmlSerializer.IgnoredAttributes(GxUserType.StateAttributesTypeMap(typeof(T))); } } return(GXXmlSerializer.Serialize(rootName, sNameSpace, ov, includeHeader, this)); }
public virtual bool FromXml(string s, GXBaseCollection <SdtMessages_Message> Messages, string sName, string sNamespace) { try { if (!string.IsNullOrEmpty(s)) { base.Clear(); GXBaseCollection <T> deserialized = GXXmlSerializer.Deserialize <GXBaseCollection <T> >(this.GetType(), s, sName, sNamespace, out List <string> serializationErrors); GXXmlSerializer.SetSoapError(context, serializationErrors); if (deserialized != null) { foreach (T item in deserialized) { item.context = context; Add(item); } return(true); } } return(false); } catch (Exception ex) { GXLogging.Error(log, "FromXml error", ex); context.nSOAPErr = -20006; GXXmlSerializer.SetSoapError(context, string.Format("Error reading {0}", this.GetType())); GXXmlSerializer.SetSoapError(context, ex.Message); while (ex.InnerException != null) { ex = ex.InnerException; GXXmlSerializer.SetSoapError(context, ex.Message); } GXUtil.ErrorToMessages("FromXML Error", ex, Messages); return(false); } }