예제 #1
0
        public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors)
        {
            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");

            errors = new ErrorResultTO();
            string error;

            IBinaryDataList targetDl = BuildTargetShape(filterShape, out error);

            IList <string> itemKeys = targetDl.FetchAllKeys();

            foreach (string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                IBinaryDataListEntry tmpEntry;
                if (payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error))
                {
                    if (entry.IsRecordset)
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        string fName            = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if (val != null)
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }
            }

            result.Append("</" + RootTag + ">");

            return(result);
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach(var key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {
                    if(entry.IsRecordset && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        var fName = entry.Namespace;
                        var val = entry.FetchScalar();
                        if(val != null && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
예제 #3
0
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");

            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach (var key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if (payload.TryGetEntry(key, out entry, out error))
                {
                    if (entry.IsRecordset && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        var fName = entry.Namespace;
                        var val   = entry.FetchScalar();
                        if (val != null && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }
            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return(tmp);
        }
예제 #4
0
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            TranslatorUtils tu = new TranslatorUtils();

            StringBuilder result = new StringBuilder("<" + RootTag + ">");

            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach (string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if (payload.TryGetEntry(key, out entry, out error))
                {
                    if (entry.IsRecordset)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while (idxItr.HasMore() && !entry.IsEmpty())
                        {
                            while (idxItr.HasMore())
                            {
                                int i = idxItr.FetchNextIndex();

                                IList <IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                                errors.AddError(error);
                                result.Append("<");
                                result.Append(entry.Namespace);
                                result.Append(">");

                                foreach (IBinaryDataListItem col in rowData)
                                {
                                    string fName = col.FieldName;

                                    result.Append("<");
                                    result.Append(fName);
                                    result.Append(">");

                                    // Travis.Frisinger 04.02.2013
                                    if (!col.IsDeferredRead)
                                    {
                                        try
                                        {
                                            result.Append(tu.CleanForEmit(col.TheValue));
                                        }
                                        catch (Exception e)
                                        {
                                            Dev2Logger.Log.Error(e);
                                        }
                                    }
                                    else
                                    {
                                        // deferred read, just print the location
                                        result.Append(!string.IsNullOrEmpty(col.TheValue) ? col.FetchDeferredLocation() : string.Empty);
                                    }
                                    result.Append("</");
                                    result.Append(fName);
                                    result.Append(">");
                                }

                                result.Append("</");
                                result.Append(entry.Namespace);
                                result.Append(">");
                            }
                        }
                    }
                    else
                    {
                        string fName            = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if (val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            // Travis.Frisinger 04.02.2013
                            if (!val.IsDeferredRead)
                            {
                                // Dev2System.FormView is our html region, pass it by ;)
                                try
                                {
                                    result.Append(!entry.IsManagmentServicePayload ? tu.CleanForEmit(val.TheValue) : val.TheValue);
                                }
                                catch (Exception e)
                                {
                                    Dev2Logger.Log.Error(e);
                                }
                            }
                            else
                            {
                                // deferred read, just print the location
                                result.Append(val.FetchDeferredLocation());
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }
            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return(tmp);
        }
예제 #5
0
        public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            ErrorResultTO invokeErrors;
            TranslatorUtils tu = new TranslatorUtils();

            IBinaryDataList targetDl = _tu.TranslateShapeToObject(filterShape, false, out invokeErrors);
            errors.MergeErrors(invokeErrors);

            IList<string> itemKeys = targetDl.FetchAllKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                IBinaryDataListEntry tmpEntry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error))
                {

                    if(entry.IsRecordset)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore())
                        {
                            var i = idxItr.FetchNextIndex();

                            IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                            if(error != string.Empty)
                            {
                                errors.AddError(error);
                            }

                            result.Append("<");
                            result.Append(entry.Namespace);
                            result.Append(" ");
                            result.Append(GlobalConstants.RowAnnotation);
                            result.Append("=");
                            result.Append("\"" + i + "\"");
                            result.Append(">");

                            foreach(IBinaryDataListItem col in rowData)
                            {
                                IBinaryDataListItem col1 = col;
                                if(tmpEntry.Columns.Any((c => c.ColumnName == col1.FieldName)))
                                {
                                    string fName = col.FieldName;

                                    result.Append("<");
                                    result.Append(fName);
                                    result.Append(">");
                                    try
                                    {
                                        result.Append(tu.FullCleanForEmit(col.TheValue));
                                    }
                                    // ReSharper disable EmptyGeneralCatchClause
                                    catch(Exception)
                                    // ReSharper restore EmptyGeneralCatchClause
                                    {
                                    }
                                    result.Append("</");
                                    result.Append(fName);
                                    result.Append(">");
                                }
                            }

                            result.Append("</");
                            result.Append(entry.Namespace);
                            result.Append(">");
                        }
                    }
                    else
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();

                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            try
                            {
                                result.Append(entry.Namespace != GlobalConstants.ManagementServicePayload ? tu.FullCleanForEmit(val.TheValue) : val.TheValue);
                            }
                            // ReSharper disable EmptyGeneralCatchClause
                            catch
                            // ReSharper restore EmptyGeneralCatchClause
                            {
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            return result;
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            TranslatorUtils tu = new TranslatorUtils();

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {

                    if(entry.IsRecordset)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore() && !entry.IsEmpty())
                        {

                            while(idxItr.HasMore())
                            {

                                int i = idxItr.FetchNextIndex();

                                IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                                errors.AddError(error);
                                result.Append("<");
                                result.Append(entry.Namespace);
                                result.Append(">");

                                foreach(IBinaryDataListItem col in rowData)
                                {
                                    string fName = col.FieldName;

                                    result.Append("<");
                                    result.Append(fName);
                                    result.Append(">");

                                    // Travis.Frisinger 04.02.2013
                                    if(!col.IsDeferredRead)
                                    {
                                        try
                                        {
                                            result.Append(tu.CleanForEmit(col.TheValue));
                                        }
                                        catch(Exception e)
                                        {
                                            Dev2Logger.Log.Error(e);
                                        }
                                    }
                                    else
                                    {
                                        // deferred read, just print the location
                                        result.Append(!string.IsNullOrEmpty(col.TheValue) ? col.FetchDeferredLocation() : string.Empty);
                                    }
                                    result.Append("</");
                                    result.Append(fName);
                                    result.Append(">");
                                }

                                result.Append("</");
                                result.Append(entry.Namespace);
                                result.Append(">");
                            }
                        }
                    }
                    else
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            // Travis.Frisinger 04.02.2013
                            if(!val.IsDeferredRead)
                            {
                                // Dev2System.FormView is our html region, pass it by ;)
                                try
                                {
                                    result.Append(!entry.IsManagmentServicePayload ? tu.CleanForEmit(val.TheValue) : val.TheValue);
                                }
                                catch(Exception e)
                                {
                                    Dev2Logger.Log.Error(e);
                                }

                            }
                            else
                            {
                                // deferred read, just print the location
                                result.Append(val.FetchDeferredLocation());
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }