/// <summary>
 /// Initializes a new instance of the <see cref="UPOfflineStorage"/> class.
 /// </summary>
 /// <param name="baseDirectoryPath">The base directory path.</param>
 /// <param name="configStore">The configuration store.</param>
 public UPOfflineStorage(string baseDirectoryPath, IConfigurationUnitStore configStore)
 {
     this.Logger                 = SimpleIoc.Default.GetInstance <ILogger>();
     this.baseDirectoryPath      = baseDirectoryPath;
     this.databaseFilename       = this.GetOfflineStoragePath("offlineDB.sql");
     this.Database               = OfflineDatabase.Create(this.databaseFilename);
     this.StoreBeforeRequest     = !configStore.ConfigValueIsSet("Disable.85260");
     this.nextId                 = this.MaxRequestIdFromDatabase();
     this.noCachedRequestNumbers = configStore.ConfigValueIsSet("Disable.79679");
     this.UnblockUpSyncRequests();
 }
Esempio n. 2
0
        private void LoadGroups()
        {
            this.Groups    = new List <UPCharacteristicsGroup>();
            this.groupDict = new Dictionary <string, UPCharacteristicsGroup>();
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (this.GroupSearchAndListControl != null)
            {
                this.GroupFieldControl = configStore.FieldControlByNameFromGroup("List", this.GroupSearchAndListControl.FieldGroupName);
                UPConfigFilter filter = null;
                if (!string.IsNullOrEmpty(this.GroupSearchAndListControl.FilterName))
                {
                    filter = configStore.FilterByName(this.GroupSearchAndListControl.FilterName);
                    if (filter != null && this.sourceFieldDictionary != null)
                    {
                        filter = filter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary));
                    }
                }

                UPConfigFieldControlField groupField = this.GroupFieldControl.FieldWithFunction(Constants.FieldGroupString);
                if (this.GroupFieldControl != null && groupField != null)
                {
                    this.crmQuery = new UPContainerMetaInfo(this.GroupFieldControl);
                    if (filter != null)
                    {
                        this.crmQuery.ApplyFilter(filter);
                    }

                    this.currentQueryType = 0;
                    this.crmQuery.Find(this.SourceRequestOption, this);
                }
            }
            else
            {
                bool      showAdditionalFields = !configStore.ConfigValueIsSet("Characteristics.HideAdditionalFields");
                bool      showExpanded         = !configStore.ConfigValueIsSet("Characteristics.CollapseGroups");
                UPCatalog catalog = UPCRMDataStore.DefaultStore.CatalogForCrmField(this.DestinationGroupField.Field);
                foreach (string key in catalog.SortedValues)
                {
                    UPCharacteristicsGroup group = new UPCharacteristicsGroup(catalog.TextValueForKey(key), key, false, this, showExpanded);
                    if (showAdditionalFields)
                    {
                        group.ShowAdditionalFields = true;
                    }

                    this.groupDict[key] = group;
                    this.Groups.Add(group);
                }

                this.LoadItems();
            }
        }
        private UPCRMResult GetResultFromContainerMetaInfo(IConfigurationUnitStore configStore)
        {
            UPCRMResult result = null;

            var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl)
            {
                ReplaceCaseSensitiveCharacters =
                    configStore.ConfigValueIsSet("Search.ReplaceCaseSensitiveCharacters")
            };

            // read record synchronously offline
            if (this.RequestOption == UPRequestOption.Default ||
                this.RequestOption == UPRequestOption.FastestAvailable ||
                this.RequestOption == UPRequestOption.Offline)
            {
                if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification))
                {
                    result = containerMetaInfo.ReadRecord(
                        StringExtensions.InfoAreaIdRecordId(this.infoAreaId, this.recordId));
                }
                else
                {
                    containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId);
                    containerMetaInfo.DisableVirtualLinks = true;
                    result = containerMetaInfo.Find();
                    if (result.RowCount >= 1)
                    {
                        this.recordId = result.ResultRowAtIndex(0).RootRecordId;
                    }
                }
            }

            if (result == null || result.RowCount < 1)
            {
                this.UpdatePage(containerMetaInfo);
            }
            else
            {
                var resultRow = result.ResultRowAtIndex(0) as UPCRMResultRow;
                this.ApplySubTitleFromResultRow(resultRow);
                this.FillPageWithResultRow(
                    this.Page,
                    resultRow,
                    (resultRow?.IsServerResponse ?? true) ? UPRequestOption.Online : UPRequestOption.Offline);
            }

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMDataStore"/> class.
        /// </summary>
        /// <param name="baseDirectoryPath">
        /// The base directory path.
        /// </param>
        /// <param name="fileName">
        /// Name of the file.
        /// </param>
        /// <param name="recreate">
        /// if set to <c>true</c> [recreate].
        /// </param>
        /// <param name="isUpdateCrm">
        /// if set to <c>true</c> [is update CRM].
        /// </param>
        /// <param name="configStore">
        /// The configuration store.
        /// </param>
        public UPCRMDataStore(
            string baseDirectoryPath,
            string fileName,
            bool recreate,
            bool isUpdateCrm,
            IConfigurationUnitStore configStore)
        {
            this.BaseDirectoryPath = baseDirectoryPath;
            this.isUpdateCrm       = isUpdateCrm;
            this.databaseFilename  = Path.Combine(this.BaseDirectoryPath, fileName);
            if (recreate)
            {
                var platformService = SimpleIoc.Default.GetInstance <IPlatformService>();
                if (platformService.StorageProvider.FileExists(this.databaseFilename))
                {
                    Exception error = null;

                    platformService.StorageProvider.TryDelete(databaseFilename, out error);
                    if (error != null)
                    {
                        Logger.LogError(error);
                    }
                }
            }

            var db = CRMDatabase.Create(isUpdateCrm, this.databaseFilename);

            this.DatabaseInstance = db;
            if (configStore.ConfigValueIsSetDefaultValue("System.DisplayFixCatBySortInfo", true))
            {
                this.DatabaseInstance.FixedCatSortBySortInfoAndCode = true;
            }

            if (recreate && !this.UpdateDDL())
            {
                return;
            }

            this.AddVirtualLinks();
            this.Reps = new UPCRMReps();

            this.VirtualInfoAreaCache = new UPVirtualInfoAreaCache();
            this.Disable86326         = configStore.ConfigValueIsSet("Disable.86326");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSearchPageModelControllerPreparedSearch"/> class.
        /// </summary>
        /// <param name="infoAreaId">
        /// The info area id.
        /// </param>
        /// <param name="quickSearchEntries">
        /// The quick search entries.
        /// </param>
        public UPSearchPageModelControllerPreparedSearch(string infoAreaId, List <QuickSearchEntry> quickSearchEntries)
        {
            this.InfoAreaId = infoAreaId;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            this.DetailAction = configStore.MenuByName(@"SHOWRECORD");

            this.ListFieldControl     = configStore.FieldControlByNameFromGroup(@"List", this.InfoAreaId);
            this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(@"MiniDetails", this.InfoAreaId);

            this.CombinedControl = this.DropdownFieldControl == null
                                       ? this.ListFieldControl
                                       : new FieldControl(
                new List <FieldControl> {
                this.ListFieldControl, this.DropdownFieldControl
            });

            this.QuickSearchEntries             = quickSearchEntries;
            this.ExpandSettings                 = configStore.ExpandByName(this.InfoAreaId);
            this.ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet(@"Search.ReplaceCaseSensitiveCharacters");
        }
        /// <summary>
        /// Applies the result row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        public override UPMGroup ApplyResultRow(UPCRMResultRow row)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            bool             hideEmptyFields    = configStore.ConfigValueIsSet("SettingsView.HideEmptyFields");
            UPMStandardGroup detailGroup        = null;
            int fieldCount = this.LayoutTab.FieldCount;

            for (int j = 0; j < fieldCount; j++)
            {
                WebConfigLayoutField fieldDef        = this.LayoutTab.FieldAtIndex(j);
                IIdentifier          fieldIdentifier = StringIdentifier.IdentifierWithStringId(fieldDef.ValueName);
                string fieldValue    = configStore.ConfigValue(fieldDef.ValueName);
                bool   hasFieldValue = !string.IsNullOrEmpty(fieldValue);

                if (!hasFieldValue && hideEmptyFields)
                {
                    continue;
                }

                var field = new UPMStringField(fieldIdentifier)
                {
                    StringValue = fieldDef.DisplayValueForValue(fieldValue),
                    LabelText   = fieldDef.Label
                };
                if (detailGroup == null)
                {
                    detailGroup           = new UPMStandardGroup(StringIdentifier.IdentifierWithStringId($"{this.Layout.UnitName}_{this.TabIndex}"));
                    detailGroup.LabelText = this.TabLabel;
                }

                detailGroup.AddField(field);
            }

            this.Group           = detailGroup;
            this.ControllerState = (detailGroup == null) ? GroupModelControllerState.Empty : GroupModelControllerState.Finished;
            return(detailGroup);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSearchPageModelControllerPreparedSearch"/> class.
        /// </summary>
        /// <param name="timelineInfoAreaConfiguration">
        /// The timeline info area configuration.
        /// </param>
        public UPSearchPageModelControllerPreparedSearch(ConfigTimelineInfoArea timelineInfoAreaConfiguration)
        {
            this.InfoAreaId            = timelineInfoAreaConfiguration.InfoAreaId;
            this.ConfigName            = timelineInfoAreaConfiguration.ConfigName;
            this.TimelineConfiguration = timelineInfoAreaConfiguration;

            if (string.IsNullOrEmpty(this.ConfigName))
            {
                this.ConfigName = this.InfoAreaId;
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            this.SearchConfiguration = configStore.SearchAndListByName(this.ConfigName);

            string fieldGroupName;

            if (this.SearchConfiguration != null)
            {
                if (this.SearchConfiguration.DefaultAction != null)
                {
                    this.DetailAction = configStore.MenuByName(this.SearchConfiguration.DefaultAction);
                }

                if (this.DetailAction == null)
                {
                    InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.InfoAreaId);

                    if (!string.IsNullOrEmpty(infoAreaConfig.DefaultAction))
                    {
                        this.DetailAction = configStore.MenuByName(infoAreaConfig.DefaultAction);
                    }
                }

                fieldGroupName = this.SearchConfiguration.FieldGroupName;
            }
            else
            {
                fieldGroupName = this.ConfigName;
            }

            this.FilterName = timelineInfoAreaConfiguration.FilterName;

            this.ListFieldControl = configStore.FieldControlByNameFromGroup(@"List", fieldGroupName);

            if (this.ListFieldControl != null)
            {
                this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(@"MiniDetails", fieldGroupName);

                if (this.DropdownFieldControl == null)
                {
                    this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(@"Details", fieldGroupName);

                    if (this.DropdownFieldControl != null)
                    {
                        this.DropdownFieldControl = this.DropdownFieldControl.FieldControlWithSingleTab(0);
                    }
                }

                this.CombinedControl = this.DropdownFieldControl == null
                                           ? this.ListFieldControl
                                           : new FieldControl(
                    new List <FieldControl>
                {
                    this.ListFieldControl,
                    this.DropdownFieldControl
                });
            }

            if (this.TimelineConfiguration.ColorCriteria.Count > 0)
            {
                Dictionary <string, UPCRMField> additionalFieldDictionary = null;

                foreach (ConfigTimelineCriteria criteria in this.TimelineConfiguration.ColorCriteria)
                {
                    if (criteria.FieldId < 0)
                    {
                        continue;
                    }

                    UPCRMField field = new UPCRMField(criteria.FieldId, this.TimelineConfiguration.InfoAreaId);

                    string key = field.FieldId.ToString();

                    if (additionalFieldDictionary == null)
                    {
                        additionalFieldDictionary = new Dictionary <string, UPCRMField>();
                    }

                    if (!additionalFieldDictionary.ContainsKey(key))
                    {
                        additionalFieldDictionary.Add(key, field);
                    }
                }

                this.AdditionalOutputFields = additionalFieldDictionary.Values.Select(x => x).ToList();
            }

            if (this.DetailAction == null)
            {
                this.DetailAction = configStore.MenuByName(@"SHOWRECORD");
            }

            this.ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet(@"Search.ReplaceCaseSensitiveCharacters");
        }
        private void Initialize(string infoAreaId, string configName, string filterName)
        {
            this.InfoAreaId = infoAreaId;
            this.ConfigName = configName;

            if (string.IsNullOrEmpty(this.ConfigName))
            {
                this.ConfigName = this.InfoAreaId;
            }

            this.FilterName = filterName;

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            this.SearchConfiguration = configStore.SearchAndListByName(this.ConfigName);

            if (this.SearchConfiguration == null)
            {
                FieldControl fieldControl = configStore.FieldControlByNameFromGroup(@"List", this.ConfigName);
                if (fieldControl != null)
                {
                    this.SearchConfiguration = new SearchAndList(fieldControl);
                }
            }

            if (this.InfoAreaId == null)
            {
                this.InfoAreaId = this.SearchConfiguration != null
                                      ? this.SearchConfiguration.InfoAreaId
                                      : this.ConfigName;
            }

            this.ExpandSettings = configStore.ExpandByName(this.ConfigName) ?? configStore.ExpandByName(this.InfoAreaId);

            if (!string.IsNullOrEmpty(this.SearchConfiguration?.DefaultAction))
            {
                this.DetailAction = configStore.MenuByName(this.SearchConfiguration.DefaultAction);
            }

            if (this.DetailAction == null)
            {
                InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.InfoAreaId);

                if (!string.IsNullOrEmpty(infoAreaConfig?.DefaultAction))
                {
                    this.DetailAction = configStore.MenuByName(infoAreaConfig.DefaultAction);
                }
            }

            if (this.DetailAction == null)
            {
                this.DetailAction = configStore.MenuByName(@"SHOWRECORD");
            }

            if (this.SearchConfiguration != null)
            {
                this.ListFieldControl = configStore.FieldControlByNameFromGroup(
                    @"List",
                    this.SearchConfiguration.FieldGroupName);

                if (this.ListFieldControl != null)
                {
                    this.SearchFieldControl = configStore.FieldControlByNameFromGroup(
                        @"Search",
                        this.SearchConfiguration.FieldGroupName);
                    this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(
                        @"MiniDetails",
                        this.SearchConfiguration.FieldGroupName);

                    if (this.DropdownFieldControl == null)
                    {
                        this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(
                            @"Details",
                            this.SearchConfiguration.FieldGroupName);

                        this.DropdownFieldControl = this.DropdownFieldControl?.FieldControlWithSingleTab(0);
                    }

                    this.CombinedControl = this.DropdownFieldControl == null
                                               ? this.ListFieldControl
                                               : new FieldControl(
                        new List <FieldControl>
                    {
                        this.ListFieldControl,
                        this.DropdownFieldControl
                    });
                }
            }

            this.ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet(@"Search.ReplaceCaseSensitiveCharacters");
        }
Esempio n. 9
0
        /// <summary>
        /// Makes the system information group.
        /// </summary>
        /// <returns></returns>
        public UPMGroup MakeSystemInfoGroup()
        {
            return(null);

#if PORTING
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            bool             hideEmptyFields    = configStore.ConfigValueIsSet("SettingsView.HideEmptyFields");
            UPMStandardGroup detailGroup        = new UPMStandardGroup(StringIdentifier.IdentifierWithStringId("systeminfo_1"));

            UPSystemInfo  systemInfo    = new UPSystemInfo();
            NSDictionary  infos         = this.GetFunctionNameDictionaryForSystemInfo(systemInfo);
            FieldControl  listControl   = null;
            ViewReference systemViewRef = new ViewReference(new List <object> {
                "fieldgroup", "SYSTEMINFO"
            }, "SystemInfoView");
            string fieldGroup = systemViewRef.ContextValueForKey("fieldgroup");
            if (fieldGroup != null)
            {
                listControl = configStore.FieldControlByNameFromGroup("List", fieldGroup);
                int row = 0;
                foreach (UPConfigFieldControlField field in listControl.Fields)
                {
                    string functionName          = field.Function;
                    string label                 = field.Label;
                    string functionNameLowerCase = functionName.ToLower();
                    if (infos.ObjectForKey(functionNameLowerCase) != null)
                    {
                        IIdentifier fieldIdentifier = StringIdentifier.IdentifierWithStringId($"Id_{functionName}");
                        string      fieldValue      = infos[functionNameLowerCase];
                        if (!string.IsNullOrEmpty(fieldValue) || !hideEmptyFields)
                        {
                            UPMStringField stringField = new UPMStringField(fieldIdentifier);
                            stringField.StringValue = fieldValue;
                            stringField.LabelText   = label;
                            if (functionName == "webversion" && ServerSession.CurrentSession().IsEnterprise)
                            {
                                stringField.StringValue = $"{fieldValue} Enterprise";
                            }

                            detailGroup.AddField(stringField);
                        }
                    }

                    row++;
                }
            }

            if (systemInfo.WebconfigParameter())
            {
                foreach (UPConfigWebConfigLayoutField configField in systemInfo.WebconfigParameter().AllValues())
                {
                    IIdentifier fieldIdentifier = StringIdentifier.IdentifierWithStringId(NSString.StringWithFormat("Id_%@", configField.ValueName()));
                    string      label           = configField.ValueName();
                    if (listControl != null)
                    {
                        UPConfigFieldControlField field = listControl.FieldWithFunction(configField.ValueName());
                        if (!string.IsNullOrEmpty(field?.Label))
                        {
                            label = field.Label;
                        }
                    }

                    UPMStringField field = new UPMStringField(fieldIdentifier);
                    field.StringValue = configField.Value();
                    field.LabelText   = label;
                    detailGroup.AddField(field);
                }
            }

            return(detailGroup);
#endif
        }