Esempio n. 1
0
        // Travis.Frisinger - 29.01.2013 : Bug 8412
        /// <summary>
        /// Shapes the dev2 definitions to data list.
        /// </summary>
        /// <param name="definitions">The definitions as binary objects</param>
        /// <param name="defType">Type of the def Input or Output</param>
        /// <param name="pushToServer"></param>
        /// <param name="errors"></param>
        /// <returns></returns>
        public StringBuilder ShapeDev2DefinitionsToDataList(IList <IDev2Definition> definitions, enDev2ArgumentType defType, bool pushToServer, out ErrorResultTO errors)
        {
            ErrorResultTO allErrors = new ErrorResultTO();
            var           dataList  = DataListUtil.ShapeDefinitionsToDataList(definitions, defType, out errors);

            allErrors.MergeErrors(errors);
            errors.ClearErrors();

            // ReSharper disable RedundantAssignment
            StringBuilder result = new StringBuilder(GlobalConstants.NullDataListID.ToString());

            // ReSharper restore RedundantAssignment

            if (pushToServer)
            {
                //  Push to server and return GUID
                byte[] data = new byte[0];
                result = new StringBuilder(_svrCompiler.ConvertTo(null, DataListFormat.CreateFormat(GlobalConstants._XML), data, dataList, out errors).ToString());
            }
            else
            {
                result = dataList; // else return the datalist as requested
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the wizard data list for a service.
        /// </summary>
        /// <param name="serviceDefinition">The service definition.</param>
        /// <returns>
        /// The string for the data list
        /// </returns>
        /// <exception cref="System.Xml.XmlException">Inputs/Outputs tags were not found in the service definition</exception>
        public string GetWizardDataListForService(string serviceDefinition)
        {
            ErrorResultTO errors;

            string inputs;
            string outputs;

            try
            {
                inputs  = DataListUtil.ExtractInputDefinitionsFromServiceDefinition(serviceDefinition);
                outputs = DataListUtil.ExtractOutputDefinitionsFromServiceDefinition(serviceDefinition);
            }
            catch
            {
                throw new XmlException("Inputs/Outputs tags were not found in the service definition");
            }

            var inputDl = GenerateWizardDataListFromDefs(inputs, enDev2ArgumentType.Input, false, out errors);

            var outputDl = GenerateWizardDataListFromDefs(outputs, enDev2ArgumentType.Output, false, out errors);

            Guid inputDlID  = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_XML), string.Empty, inputDl, out errors);
            Guid outputDlID = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_XML), string.Empty, outputDl, out errors);
            Guid mergedDlID = Merge(inputDlID, outputDlID, enDataListMergeTypes.Union, enTranslationDepth.Shape, true, out errors);
            var  result     = ConvertFrom(mergedDlID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), enTranslationDepth.Shape, out errors);

            return(result.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Converts to selected Type from binary
        /// </summary>
        /// <param name="curDlid">The cur DLID.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public StringBuilder ConvertFrom(Guid curDlid, DataListFormat typeOf, enTranslationDepth depth, out ErrorResultTO errors)
        {
            DataListTranslatedPayloadTO tmp = _svrCompiler.ConvertFrom(null, curDlid, depth, typeOf, out errors);

            if (tmp != null)
            {
                return(tmp.FetchAsString());
            }

            return(new StringBuilder());
        }
        /// <summary>
        /// Gets the DatalistFormat instance that represents the given <paramref name="formatName" />, or creates a new one if a DatalistFormat instance
        /// does not exist for the given <paramref name="formatName" />.
        /// </summary>
        /// <param name="formatName">The display name of the datalist format.</param>
        /// <param name="publicFormatName">Name of the public format.</param>
        /// <param name="headerType">Type of the header.</param>
        /// <returns>
        /// An instance of the DatalistFormat type that is unique to the given <paramref name="formatName" />
        /// </returns>
        /// <exception cref="System.ArgumentException">formatName cannot be null or empty string.</exception>
        public static DataListFormat CreateFormat(string formatName, EmitionTypes publicFormatName = EmitionTypes.XML, string headerType = "")
        {
            if(String.IsNullOrEmpty(formatName)) throw new ArgumentException("formatName cannot be null or empty string.");
            DataListFormat format;

            lock(_formatLock)
            {
                if(!_existingFormats.TryGetValue(formatName, out format))
                {
                    format = new DataListFormat(formatName, publicFormatName, headerType);
                    _existingFormats.Add(formatName, format);
                }
            }

            return format;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the wizard data list for a workflow.
        /// </summary>
        /// <param name="dataList"></param>
        /// <returns>
        /// The string for the data list
        /// </returns>
        /// <exception cref="System.Exception">
        /// </exception>
        public string GetWizardDataListForWorkflow(string dataList)
        {
            IBinaryDataList newDl = Dev2BinaryDataListFactory.CreateDataList();
            ErrorResultTO   errors;
            var             dataListStringBuilder = new StringBuilder(dataList);
            Guid            dlID = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), dataListStringBuilder, dataListStringBuilder, out errors);

            if (!errors.HasErrors())
            {
                IBinaryDataList dl = FetchBinaryDataList(dlID, out errors);
                if (!errors.HasErrors())
                {
                    IList <IBinaryDataListEntry> entries = dl.FetchAllEntries();
                    foreach (IBinaryDataListEntry entry in entries)
                    {
                        if (entry.IsRecordset)
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                newDl.TryCreateRecordsetTemplate(entry.Namespace, entry.Description, entry.Columns, true, out tmpError);
                            }
                        }
                        else
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                IBinaryDataListItem scalar = entry.FetchScalar();
                                newDl.TryCreateScalarTemplate(string.Empty, scalar.FieldName, entry.Description, true, out tmpError);
                            }
                        }
                    }
                    Guid newDlId = PushBinaryDataList(newDl.UID, newDl, out errors);
                    dataList = ConvertFrom(newDlId, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Shape, out errors).ToString();
                }
                else
                {
                    throw new Exception(errors.MakeUserReady());
                }
            }
            else
            {
                throw new Exception(errors.MakeUserReady());
            }
            return(dataList);
        }
Esempio n. 6
0
        /// <summary>
        /// Generates the data list from defs.
        /// </summary>
        /// <param name="definitions">The definitions as binary objects</param>
        /// <param name="pushToServer">if set to <c>true</c> [push to server]. the GUID is returned</param>
        /// <param name="errors">The errors.</param>
        /// <param name="withData"></param>
        /// <returns></returns>
        public StringBuilder GenerateDataListFromDefs(IList <IDev2Definition> definitions, bool pushToServer, out ErrorResultTO errors, bool withData = false)
        {
            errors = new ErrorResultTO();
            var           dataList = GenerateDataListFromDefs(definitions, withData);
            StringBuilder result;

            if (pushToServer)
            {
                byte[] data = new byte[0];
                result = new StringBuilder(_svrCompiler.ConvertTo(null, DataListFormat.CreateFormat(GlobalConstants._XML), data, dataList, out errors).ToString());
            }
            else
            {
                result = dataList;
            }

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// Shapes the dev2 definitions to data list.
        /// </summary>
        /// <param name="definitions">The definitions as string</param>
        /// <param name="defType">Type of the def.</param>
        /// <param name="pushToServer">if set to <c>true</c> [push to server].</param>
        /// <param name="errors">The errors.</param>
        /// <param name="flipGeneration">if set to <c>true</c> [flip generation].</param>
        /// <returns></returns>
        public StringBuilder ShapeDev2DefinitionsToDataList(string definitions, enDev2ArgumentType defType, bool pushToServer, out ErrorResultTO errors, bool flipGeneration = false)
        {
            var           dataList = ShapeDefinitionsToDataList(definitions, defType, out errors, flipGeneration);
            StringBuilder result;

            if (pushToServer)
            {
                //  Push to server and return GUID
                byte[] data = new byte[0];
                result = new StringBuilder(_svrCompiler.ConvertTo(null, DataListFormat.CreateFormat(GlobalConstants._XML), data, dataList, out errors).ToString());
            }
            else
            {
                result = dataList; // else return the datalist as requested
            }

            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the DatalistFormat instance that represents the given <paramref name="formatName" />, or creates a new one if a DatalistFormat instance
        /// does not exist for the given <paramref name="formatName" />.
        /// </summary>
        /// <param name="formatName">The display name of the datalist format.</param>
        /// <param name="publicFormatName">Name of the public format.</param>
        /// <param name="headerType">Type of the header.</param>
        /// <returns>
        /// An instance of the DatalistFormat type that is unique to the given <paramref name="formatName" />
        /// </returns>
        /// <exception cref="System.ArgumentException">formatName cannot be null or empty string.</exception>
        public static DataListFormat CreateFormat(string formatName, EmitionTypes publicFormatName = EmitionTypes.XML, string headerType = "")
        {
            if (String.IsNullOrEmpty(formatName))
            {
                throw new ArgumentException("formatName cannot be null or empty string.");
            }
            DataListFormat format;

            lock (_formatLock)
            {
                if (!_existingFormats.TryGetValue(formatName, out format))
                {
                    format = new DataListFormat(formatName, publicFormatName, headerType);
                    _existingFormats.Add(formatName, format);
                }
            }

            return(format);
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the DatalistFormat instance that represents the given <paramref name="formatName" />, or creates a new one if a DatalistFormat instance
        /// does not exist for the given <paramref name="formatName" />.
        /// </summary>
        /// <param name="formatName">The display name of the datalist format.</param>
        /// <param name="publicFormatName">Name of the public format.</param>
        /// <param name="headerType">Type of the header.</param>
        /// <returns>
        /// An instance of the DatalistFormat type that is unique to the given <paramref name="formatName" />
        /// </returns>
        /// <exception cref="System.ArgumentException">formatName cannot be null or empty string.</exception>
        public static DataListFormat CreateFormat(string formatName, EmitionTypes publicFormatName = EmitionTypes.XML, string headerType = "")
        {
            if (String.IsNullOrEmpty(formatName))
            {
                throw new ArgumentException(ErrorResource.FormatNameCannotBeNull);
            }
            DataListFormat format;

            lock (FormatLock)
            {
                if (!ExistingFormats.TryGetValue(formatName, out format))
                {
                    format = new DataListFormat(formatName, publicFormatName, headerType);
                    ExistingFormats.Add(formatName, format);
                }
            }

            return(format);
        }
 public DataListJsonTranslator()
 {
     _format = DataListFormat.CreateFormat(GlobalConstants._JSON, EmitionTypes.JSON, "application/json");
     _encoding = Encoding.UTF8;
 }
 public DataListXMLTranslatorWithOutSystemTags()
 {
     _format = DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags, EmitionTypes.XML, "text/xml");
     _encoding = Encoding.UTF8;
     _tu = new TranslatorUtils();
 }
Esempio n. 12
0
 /// <summary>
 /// Converts the and filter.
 /// </summary>
 /// <param name="curDlid">The cur DLID.</param>
 /// <param name="typeOf">The type of.</param>
 /// <param name="filterShape">The filter shape.</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public StringBuilder ConvertAndFilter(Guid curDlid, DataListFormat typeOf, StringBuilder filterShape, out ErrorResultTO errors)
 {
     return(_svrCompiler.ConvertAndFilter(null, curDlid, filterShape, typeOf, out errors));
 }
Esempio n. 13
0
 /// <summary>
 /// Populates the data list.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 /// <param name="input">The input.</param>
 /// <param name="outputDefs">The output defs.</param>
 /// <param name="targetDlid">The target dlid.</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public Guid PopulateDataList(DataListFormat typeOf, object input, string outputDefs, Guid targetDlid, out ErrorResultTO errors)
 {
     return(_svrCompiler.PopulateDataList(null, typeOf, input, outputDefs, targetDlid, out errors));
 }
Esempio n. 14
0
 /// <summary>
 /// Converts the and only map inputs.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 /// <param name="payload">The payload.</param>
 /// <param name="shape">The shape.</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public Guid ConvertAndOnlyMapInputs(DataListFormat typeOf, StringBuilder payload, StringBuilder shape, out ErrorResultTO errors)
 {
     byte[] data = Encoding.UTF8.GetBytes(payload.ToString());
     return(_svrCompiler.ConvertAndOnlyMapInputs(null, typeOf, data, shape, out errors));
 }
Esempio n. 15
0
 /// <summary>
 /// Converts to.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 /// <param name="payload">The payload.</param>
 /// <param name="shape">The shape.</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public Guid ConvertTo(DataListFormat typeOf, object payload, StringBuilder shape, out ErrorResultTO errors)
 {
     return(_svrCompiler.ConvertTo(null, typeOf, payload, shape, out errors));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 protected StudioTranslator(DataListFormat format, Encoding encoding)
 {
     Format = format;
     TextEncoding = encoding;
 }
 public bool RemoveTranslator(DataListFormat format)
 {
     if(format == null) throw new ArgumentNullException("format");
     lock(_translatorGuard) return _translators.Remove(format);
 }
 public bool ContainsTranslator(DataListFormat format)
 {
     if(format == null) throw new ArgumentNullException("format");
     lock(_translatorGuard) return _translators.ContainsKey(format);
 }
        public IDataListTranslator GetTranslator(DataListFormat format)
        {
            if(format == null) throw new ArgumentNullException("format");
            IDataListTranslator result;

            lock(_translatorGuard)
            {
                if(!_translators.TryGetValue(format, out result))
                {
                    return null;
                }
            }

            return result;
        }
 public StudioDataListXMLTranslator()
 {
     _format = DataListFormat.CreateFormat(GlobalConstants._Studio_XML);
     _encoding = Encoding.UTF8;
 }