Пример #1
0
        /// <summary>
        /// Loads the with result row.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <returns></returns>
        public override bool LoadWithResultRow(UPCRMResultRow resultRow)
        {
            if (this.tableCaption != null)
            {
                string tc    = this.tableCaption.TableCaptionForResultRow(resultRow, false);
                var    parts = tc.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                if (parts.Length > 1)
                {
                    this.Value = parts[0];
                    this.Text  = parts[1];
                }
                else
                {
                    this.Value = tc;
                    this.Text  = this.tableCaption.Fields[0].Label;
                }
            }
            else
            {
                this.Text = this.tableCaption.Fields[0].Label;
            }

            if (this.catalogAttributes != null)
            {
                string rawValue = resultRow.RawValueForFieldIdInfoAreaIdLinkId(this.catalogAttributes.CrmField.FieldId, this.catalogAttributes.CrmField.InfoAreaId, -1);
                if (!string.IsNullOrEmpty(rawValue))
                {
                    this.ImageName = this.catalogAttributes.ImageNameForRawValue(rawValue);
                }
            }

            this.Tiles.TileFinished(this);
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public virtual void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            int count = result.RowCount;

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(i);
                var            rowValues = resultRow.ValuesWithFunctions();

                string rep   = (string)rowValues.ValueOrDefault(Constants.UPRepAcceptanceFunctionName_RepId);
                int    repId = rep.ToInt();

                if (repId > 0)
                {
                    rep = StringExtensions.NineDigitStringFromRep(Convert.ToInt32(rep));

                    var repParticipant = this.ParticipantWithKey(rep);

                    if (repParticipant is UPCRMRepParticipant)
                    {
                        string acceptance = (string)rowValues[Constants.UPRepAcceptanceFunctionName_Acceptance];
                        ((UPCRMRepParticipant)repParticipant).AcceptanceFromRecordIdentification(acceptance, resultRow.RootRecordIdentification);
                    }
                }
            }

            this.repAcceptanceCrmQuery = null;
            this.Loaded();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMLinkParticipant"/> class.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <param name="index">The index.</param>
        public UPCRMLinkParticipant(UPCRMResultRow resultRow, int index)
            : base(resultRow.RootRecordIdentification)
        {
            this.RecordIdentification     = resultRow.RootRecordIdentification;
            this.LinkRecordIdentification = resultRow.RecordIdentificationAtIndex(index);
            this.IsNewParticipant         = false;

            var functionNameValues = resultRow.ValuesWithFunctions();

            this.RequirementText        = (string)functionNameValues["Requirement"];
            this.AcceptanceText         = (string)functionNameValues["Acceptance"];
            this.OriginalAcceptanceText = this.AcceptanceText;

            UPContainerInfoAreaMetaInfo infoAreaMetaInfo = resultRow.Result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(index);

            this._name = TableCaptionForInfoAreaIdResultRow(this.LinkRecordIdentification.InfoAreaId(), resultRow);

            if (string.IsNullOrEmpty(this._name))
            {
                this._name = string.Empty;
                foreach (UPContainerFieldMetaInfo field in infoAreaMetaInfo.Fields)
                {
                    string val = resultRow.ValueForField(field);
                    if (!string.IsNullOrEmpty(val))
                    {
                        this._name = this._name.Length > 0 ? $"{this._name} {val}" : val;
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Tables the caption for information area identifier result row.
        /// </summary>
        /// <param name="infoAreaId">The information area identifier.</param>
        /// <param name="resultRow">The result row.</param>
        /// <returns></returns>
        public static string TableCaptionForInfoAreaIdResultRow(string infoAreaId, UPCRMResultRow resultRow)
        {
            var store = ConfigurationUnitStore.DefaultStore;
            UPConfigTableCaption tableCaption = store.TableCaptionByName($"{infoAreaId}Part") ??
                                                store.TableCaptionByName(infoAreaId);

            return(tableCaption != null?tableCaption.TableCaptionForResultRow(resultRow) : string.Empty);
        }
Пример #5
0
        /// <summary>
        /// The read link record identification from row.
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string ReadLinkRecordIdentificationFromRow(UPCRMResultRow row)
        {
            if (!this.LinkInfo.UseLinkFields)
            {
                return(null);
            }

            int    nextIndex              = this.StartingPosition;
            string targetInfoAreaId       = this.LinkInfo.TargetInfoAreaId;
            UPContainerMetaInfo query     = new UPContainerMetaInfo(new List <UPCRMField>(), targetInfoAreaId);
            UPInfoAreaCondition condition = null;

            foreach (UPCRMLinkInfoField linkInfoField in this.LinkInfo.LinkFieldArray)
            {
                UPInfoAreaCondition leaf;
                if (linkInfoField.FieldId >= 0)
                {
                    string value = row.RawValueAtIndex(nextIndex++);
                    if (linkInfoField.TargetFieldId < 0)
                    {
                        if (!value.Equals(linkInfoField.TargetValue))
                        {
                            return(null);
                        }
                    }

                    leaf = new UPInfoAreaConditionLeaf(targetInfoAreaId, linkInfoField.TargetFieldId, value);
                }
                else
                {
                    leaf = new UPInfoAreaConditionLeaf(
                        targetInfoAreaId,
                        linkInfoField.TargetFieldId,
                        linkInfoField.SourceValue);
                }

                condition = condition != null?condition.InfoAreaConditionByAppendingAndCondition(leaf) : leaf;
            }

            if (condition != null)
            {
                query.RootInfoAreaMetaInfo.AddCondition(condition);
            }

            UPCRMResult result = query.Find();

            if (result.RowCount >= 1)
            {
                return(((UPCRMResultRow)result.ResultRowAtIndex(0)).RootRecordIdentification);
            }

            return(null);
        }
Пример #6
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            if (this.crmQuery != null)
            {
                int count         = result.RowCount;
                int infoAreaCount = result.MetaInfo.NumberOfResultInfoAreaMetaInfos();

                for (int i = 0; i < count; i++)
                {
                    UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(i);

                    for (int j = 1; j < infoAreaCount; j++)
                    {
                        string linkRecordIdentification = resultRow.RecordIdentificationAtIndex(j);
                        if (linkRecordIdentification?.Length > 6)
                        {
                            UPCRMLinkParticipant linkParticipant = new UPCRMLinkParticipant(resultRow, j);
                            this.AddLinkParticipant(linkParticipant);

                            if (!string.IsNullOrEmpty(this.ProtectedLinkRecordIdentification) && this.ProtectedLinkRecordIdentification == linkParticipant.LinkRecordIdentification)
                            {
                                linkParticipant.MayNotBeDeleted = true;
                            }

                            break;
                        }
                        else
                        {
                            UPContainerInfoAreaMetaInfo iaMeta      = result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(j);
                            UPCRMLinkReader             _linkReader = new UPCRMLinkReader(resultRow.RootRecordIdentification, iaMeta.InfoAreaIdWithLink, null);
                            string linkRecordId = _linkReader.RequestLinkRecordOffline();

                            if (!string.IsNullOrEmpty(linkRecordId) && UPCRMDataStore.DefaultStore.RecordExistsOffline(linkRecordId))
                            {
                                UPCRMLinkParticipant linkParticipant = new UPCRMLinkParticipant(resultRow, linkRecordId);
                                this.AddLinkParticipant(linkParticipant);
                                break;
                            }
                        }
                    }
                }

                this.Finished(null);
            }
            else
            {
                base.SearchOperationDidFinishWithResult(operation, result);
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMLinkParticipant"/> class.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <param name="linkRecordIdentification">The link record identification.</param>
        public UPCRMLinkParticipant(UPCRMResultRow resultRow, string linkRecordIdentification)
            : base(resultRow.RootRecordIdentification)
        {
            this.RecordIdentification      = resultRow.RootRecordIdentification;
            this.LinkRecordIdentification  = linkRecordIdentification;
            this.IsOfflineEmptyParticipant = true;

            var functionNameValues = resultRow.ValuesWithFunctions();

            this.RequirementText        = (string)functionNameValues["Requirement"];
            this.AcceptanceText         = (string)functionNameValues["Acceptance"];
            this.OriginalAcceptanceText = this.AcceptanceText;

            this._name = LocalizedString.TextOfflineNotAvailable;
        }
Пример #8
0
        /// <summary>
        /// The handle result client.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <param name="client">
        /// The client.
        /// </param>
        public void HandleResultClient(UPCRMResult result, bool client)
        {
            if (this.queryWithLinkRecord)
            {
                if (result.RowCount > 0)
                {
                    UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(0);
                    this.DestinationRecordIdentification = resultRow.RootRecordIdentification;
                }
            }
            else
            {
                UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0);
                if (client)
                {
                    this.DestinationRecordIdentification = this.RecordIdentificationFromResultRow(row);
                }
                else
                {
                    int position = 0;
                    Dictionary <string, int> linkPositions = new Dictionary <string, int>();
                    foreach (UPCRMLinkReaderLinkContext context in this.linkContexts)
                    {
                        string linkKey = $"{context.LinkInfo.TargetInfoAreaId}_{(context.LinkInfo.LinkId < 0 ? 0 : context.LinkInfo.LinkId)}";
                        if (linkPositions.ValueOrDefault(linkKey) == 0)
                        {
                            continue;
                        }

                        this.DestinationRecordIdentification = row.RecordIdentificationAtIndex(++position);
                        if (!string.IsNullOrEmpty(this.DestinationRecordIdentification))
                        {
                            break;
                        }

                        linkPositions[linkKey] = position - 1;
                    }
                }
            }

            this.TheDelegate?.LinkReaderDidFinishWithResult(this, this.DestinationRecordIdentification);
        }
Пример #9
0
        /// <summary>
        /// The record identification from result row.
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string RecordIdentificationFromResultRow(UPCRMResultRow row)
        {
            foreach (UPCRMLinkReaderLinkContext context in this.linkContexts)
            {
                if (context.LinkInfo.LinkId <= 0 && context.LinkInfo.TargetInfoAreaId.Equals(this.InfoAreaId))
                {
                    return(this.SourceRecordIdentification);
                }

                if (context.LinkField != null)
                {
                    string val = row.RawValueAtIndex(context.StartingPosition);
                    if (!string.IsNullOrEmpty(val))
                    {
                        return(context.LinkInfo.TargetInfoAreaId.InfoAreaIdRecordId(val));
                    }
                }
                else if (context.FieldLinkFields.Count == 2 && context.LinkInfo.LinkFieldArray.Count == context.FieldLinkFields.Count)
                {
                    string statNoValue = row.RawValueAtIndex(context.StartingPosition);
                    string lNrValue    = row.RawValueAtIndex(context.StartingPosition + 1);
                    if (!string.IsNullOrEmpty(lNrValue) && lNrValue != "0")
                    {
                        return(StringExtensions.InfoAreaIdRecordId(
                                   context.LinkInfo.TargetInfoAreaId,
                                   StringExtensions.RecordIdFromStatNoStringRecordNoString(statNoValue, lNrValue)));
                    }
                }
                else
                {
                    string linkRecord = context.ReadLinkRecordIdentificationFromRow(row);
                    if (!string.IsNullOrEmpty(linkRecord))
                    {
                        return(linkRecord);
                    }
                }
            }

            return(null);
        }
Пример #10
0
        /// <summary>
        /// The request link record offline.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string RequestLinkRecordOffline()
        {
            this.linkContexts = this.LinkReaderContextsForParentLinkString(this.ParentLinkString);
            if (this.linkContexts == null || this.linkContexts.Count == 0)
            {
                return(null);
            }

            if (this.linkContexts.Count == 1)
            {
                UPCRMLinkReaderLinkContext context = this.linkContexts[0];
                if (context.LinkInfo.IsGeneric)
                {
                    UPContainerMetaInfo crmQuery = this.QueryForLinkLinkRecord(context.LinkInfo, this.SourceRecordIdentification);
                    UPCRMResult         result   = crmQuery.Find();
                    if (result.RowCount > 0)
                    {
                        UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0);
                        return(row.RootRecordIdentification);
                    }

                    return(null);
                }
            }

            UPContainerMetaInfo crmQuery2 = this.ClientQuery();
            UPCRMResult         result2   = crmQuery2.Find();

            if (result2.RowCount == 0)
            {
                return(null);
            }

            UPCRMResultRow row2 = (UPCRMResultRow)result2.ResultRowAtIndex(0);

            return(this.RecordIdentificationFromResultRow(row2));
        }
 /// <summary>
 /// Checks the specified row.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public virtual bool Check(UPCRMResultRow row) => true;
Пример #12
0
        /// <summary>
        /// Sources the field result row for link.
        /// </summary>
        /// <param name="link">The link.</param>
        /// <returns></returns>
        List <string> SourceFieldResultRowForLink(UPCRMLink link)
        {
            UPCRMTableInfo sourceTableInfo = this.dataStore.TableInfoForInfoArea(link.InfoAreaId);
            UPCRMLinkInfo  linkInfo        = this.tableInfo.LinkInfoForTargetInfoAreaIdLinkId(link.InfoAreaId, link.LinkId);
            bool           noFields        = true;

            if (sourceTableInfo == null || linkInfo?.LinkFieldArray == null)
            {
                return(null);
            }

            List <UPCRMFieldSetterField> fieldMap = new List <UPCRMFieldSetterField>(linkInfo.LinkFieldArray.Count);

            foreach (UPCRMLinkInfoField field in linkInfo.LinkFieldArray)
            {
                UPCRMFieldInfo fieldInfo = sourceTableInfo.FieldInfoForFieldId(field.TargetFieldId);
                if (fieldInfo != null)
                {
                    fieldMap.Add(new UPCRMFieldSetterSourceField(field.TargetFieldId));
                    noFields = false;
                }
                else
                {
                    UPCRMFieldSetterSourceLink sourceLink = null;
                    List <UPCRMLinkInfo>       allLinks   = sourceTableInfo.LinksWithField();
                    foreach (UPCRMLinkInfo currentLinkInfo in allLinks)
                    {
                        foreach (UPCRMLinkInfoField linkInfoField in currentLinkInfo.LinkFieldArray)
                        {
                            if (linkInfoField.FieldId == field.TargetFieldId)
                            {
                                UPCRMTableInfo parentTableInfo = this.dataStore.TableInfoForInfoArea(currentLinkInfo.TargetInfoAreaId);
                                UPCRMLinkInfo  parentIdentLink = parentTableInfo.IdentLink;
                                if (parentIdentLink != null)
                                {
                                    if (parentIdentLink.FirstField.TargetFieldId == linkInfoField.TargetFieldId)
                                    {
                                        sourceLink = new UPCRMFieldSetterSourceLink(currentLinkInfo.TargetInfoAreaId, currentLinkInfo.LinkId, 0);
                                        break;
                                    }

                                    if (parentIdentLink.SecondField.TargetFieldId == linkInfoField.TargetFieldId)
                                    {
                                        sourceLink = new UPCRMFieldSetterSourceLink(currentLinkInfo.TargetInfoAreaId, currentLinkInfo.LinkId, 1);
                                        break;
                                    }
                                }
                            }
                        }

                        if (sourceLink != null)
                        {
                            break;
                        }
                    }

                    if (sourceLink != null)
                    {
                        fieldMap.Add(sourceLink);
                        noFields = false;
                    }
                    else
                    {
                        fieldMap.Add(new UPCRMFieldSetterField());
                    }
                }
            }

            if (noFields)
            {
                return(null);
            }

            List <UPCRMField> queryFields = new List <UPCRMField>();
            int resultPosition            = 0;

            foreach (UPCRMFieldSetterField fieldSetterField in fieldMap)
            {
                if (fieldSetterField.IsField)
                {
                    queryFields.Add(fieldSetterField.FieldWithInfoAreaId(link.InfoAreaId));
                    fieldSetterField.ResultPosition = resultPosition++;
                }
            }

            foreach (UPCRMFieldSetterField fieldSetterField in fieldMap)
            {
                if (fieldSetterField.IsLink)
                {
                    queryFields.Add(fieldSetterField.FieldWithInfoAreaId(link.InfoAreaId));
                    fieldSetterField.ResultPosition = resultPosition++;
                }
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(queryFields, linkInfo.TargetInfoAreaId);
            UPCRMResult         result   = crmQuery.ReadRecord(link.RecordIdentification);

            if (result != null && result.RowCount == 1)
            {
                UPCRMResultRow row         = (UPCRMResultRow)result.ResultRowAtIndex(0);
                List <string>  resultArray = new List <string>(fieldMap.Count);
                foreach (UPCRMFieldSetterField field in fieldMap)
                {
                    if (field.IsField)
                    {
                        resultArray.Add(row.RawValueAtIndex(field.ResultPosition));
                    }
                    else if (field.IsLink)
                    {
                        string recordId = row.RawValueAtIndex(field.ResultPosition);
                        if (string.IsNullOrEmpty(recordId))
                        {
                            resultArray.Add(string.Empty);
                        }
                        else if (recordId.StartsWith("new") && recordId.Length == 15)
                        {
                            long offlineLnr = (Convert.ToInt64(recordId.Substring(3, 8), 16) << 16) + Convert.ToInt64(recordId.Substring(11, 4), 16);
                            if (this.offlineStationNumber > 0 && offlineLnr > 0)
                            {
                                if (((UPCRMFieldSetterSourceLink)field).FieldIndex == 0)
                                {
                                    resultArray.Add(this.offlineStationNumber.ToString());
                                }
                                else
                                {
                                    resultArray.Add(offlineLnr.ToString());
                                }
                            }
                        }
                        else if (((UPCRMFieldSetterSourceLink)field).FieldIndex == 0)
                        {
                            resultArray.Add(recordId.StatNoFromRecordIdString());
                        }
                        else
                        {
                            resultArray.Add(recordId.RecordNoFromRecordIdString());
                        }
                    }
                    else
                    {
                        resultArray.Add(string.Empty);
                    }
                }

                return(resultArray);
            }

            return(null);
        }
 /// <summary>
 /// Loads the with result row.
 /// </summary>
 /// <param name="resultRow">The result row.</param>
 /// <returns></returns>
 public virtual bool LoadWithResultRow(UPCRMResultRow resultRow)
 {
     return(false);
 }
 /// <summary>
 /// Checks the specified row.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public override bool Check(UPCRMResultRow row)
 {
     return(this.Conditions.All(condition => condition.Check(row)));
 }