Esempio n. 1
0
        /// <inheritdoc/>
        public void UpdateSettingsFromSession(IConfigurationUnitStore configStore)
        {
            this.LogReportEmailAddress = configStore?.ConfigValue("LogReport.EmailAddress") ?? string.Empty;
            if (configStore == null || this.OverrideServerSettings)
            {
                return;
            }

            this.LogClass         = configStore.ConfigValue("Log.Class");
            this.LogMethod        = configStore.ConfigValue("Log.LogMethod");
            this.LogConfig        = this.AsBooleanSetting(configStore.ConfigValue("Log.Config"));
            this.LogNetwork       = this.AsBooleanSetting(configStore.ConfigValue("Log.Network"));
            this.LogQuestionnaire = this.AsBooleanSetting(configStore.ConfigValue("Log.Questionnaire"));
            this.LogRequests      = this.AsBooleanSetting(configStore.ConfigValue("Log.Requests"));
            this.LogResults       = this.AsBooleanSetting(configStore.ConfigValue("Log.Result"));
            this.LogSerialEntry   = this.AsBooleanSetting(configStore.ConfigValue("Log.SerialEntry"));
            this.LogStatements    = this.AsBooleanSetting(configStore.ConfigValue("Log.Statements"));
            this.LogUpSync        = this.AsBooleanSetting(configStore.ConfigValue("Log.UpSync"));
            this.LogFlags         = this.GetLogFlags();
            var logLevel = "4"; //configStore.ConfigValue("Log.Level");

            this.LogLevel = LogLevel.Debug;
            if (!string.IsNullOrWhiteSpace(logLevel))
            {
                var val = 1;
                if (int.TryParse(logLevel, out val) && Enum.IsDefined(typeof(LogLevel), val))
                {
                    this.LogLevel = (LogLevel)val;
                }
            }
        }
        /// <summary>
        /// Returns collection of filter
        /// </summary>
        /// <param name="configStore">
        /// <see cref="IConfigurationUnitStore"/>
        /// </param>
        /// <returns>
        /// List of <see cref="UPConfigFilter"/>
        /// </returns>
        private List <UPConfigFilter> GetFilterArray(IConfigurationUnitStore configStore)
        {
            var filterArray = new List <UPConfigFilter>();

            for (var number = 1; number <= FilterKeyCount; number++)
            {
                var filterName = ViewReference.ContextValueForKey($"Filter{number}");

                if (!string.IsNullOrWhiteSpace(filterName))
                {
                    var filter = configStore.FilterByName(filterName);
                    filterArray.Add(filter);
                }
                else
                {
                    filterArray.Add(null);
                }
            }

            var addFilters = ViewReference.ContextValueForKey(KeyAdditionalFilter);

            if (!string.IsNullOrWhiteSpace(addFilters))
            {
                var filterParts = addFilters.Split(';');
                foreach (var filterPart in filterParts)
                {
                    var filter = !string.IsNullOrWhiteSpace(filterPart) ? configStore.FilterByName(filterPart) : null;
                    filterArray.Add(filter);
                }
            }

            return(filterArray);
        }
Esempio n. 3
0
        private static void AddImageToNode(UPMCoINode node, string infoArea, string virtualInfoArea, UPConfigExpand expandChecker, UPCRMResultRow row)
        {
            // Add Image
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPConfigExpand          expand      = null;
            string imageName = null;

            if (!string.IsNullOrEmpty(virtualInfoArea))
            {
                expand = ConfigurationUnitStore.DefaultStore.ExpandByName(virtualInfoArea);
            }

            if (expand == null && expandChecker != null)
            {
                expand = expandChecker.ExpandForResultRow(row);
            }

            if (expand != null)
            {
                imageName = expand.ImageName;
            }

            if (string.IsNullOrEmpty(imageName))
            {
                InfoArea infoAreaConfig = configStore.InfoAreaConfigById(infoArea);
                imageName = infoAreaConfig.ImageName;
            }

            if (!string.IsNullOrEmpty(imageName))
            {
                //node.Icon = UIImage.UpImageWithFileName(imageName);   // CRM-5007
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSyncDataSets"/> class.
        /// </summary>
        /// <param name="dataSetNames">
        /// The data set names.
        /// </param>
        /// <param name="incremental">
        /// if set to <c>true</c> [incremental].
        /// </param>
        /// <param name="session">
        /// The session.
        /// </param>
        /// <param name="crmDataStore">
        /// The CRM data store.
        /// </param>
        /// <param name="configStore">
        /// The configuration store.
        /// </param>
        /// <param name="theDelegate">
        /// The delegate.
        /// </param>
        public UPSyncDataSets(
            List <string> dataSetNames,
            bool incremental,
            IServerSession session,
            ICRMDataStore crmDataStore,
            IConfigurationUnitStore configStore,
            ISyncDataSetsDelegate theDelegate)
        {
            this.Delegate    = theDelegate;
            this.Session     = session;
            this.DataStore   = crmDataStore;
            this.ConfigStore = configStore;

            var dataSetArray = dataSetNames == null
                                   ? new List <UPSyncDataSet>()
                                   : new List <UPSyncDataSet>(dataSetNames.Count);
            var dataSets = dataSetNames?.Select(dataSetName => new UPSyncDataSet(dataSetName, incremental, crmDataStore));

            if (dataSets != null && dataSets.Any())
            {
                dataSetArray.AddRange(dataSets);
            }

            this.DataSets = dataSetArray;
        }
Esempio n. 5
0
        private void ContinueBuildDetailsOrganizerPage()
        {
            IConfigurationUnitStore configStore  = ConfigurationUnitStore.DefaultStore;
            FieldControl            fieldControl = configStore.FieldControlByNameFromGroup("Details", this.ExpandConfig.FieldGroupName);

            this.TilesName = fieldControl.ValueForAttribute("tiles");
            bool hasCopyFields = false;

            foreach (FieldControlTab tab in fieldControl.Tabs)
            {
                if (tab.Fields != null)
                {
                    if (tab.Fields.Any(field => !string.IsNullOrEmpty(field.Function) && field.Function != "="))
                    {
                        hasCopyFields = true;
                    }
                }

                if (hasCopyFields)
                {
                    break;
                }
            }

            if (!hasCopyFields)
            {
                this.ContinueWithCopyFieldsLoaded(null);
            }
            else
            {
                this.CopyFields = new UPCopyFields(fieldControl);
                this.CopyFields.CopyFieldValuesForRecordIdentification(this.RecordIdentification, false, this);
            }
        }
Esempio n. 6
0
        private void LoadConfigFieldControlForFieldGroup(string fieldGroup)
        {
            IConfigurationUnitStore configStore         = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndListConfig = configStore.SearchAndListByName(fieldGroup);
            FieldControl            configFieldControl;
            UPConfigFilter          configFilter = null;

            if (searchAndListConfig != null)
            {
                configFieldControl = configStore.FieldControlByNameFromGroup("List", fieldGroup);
                if (!string.IsNullOrEmpty(searchAndListConfig.FilterName))
                {
                    configFilter = configStore.FilterByName(searchAndListConfig.FilterName);
                }
            }
            else
            {
                configFieldControl = configStore.FieldControlByNameFromGroup("List", fieldGroup);
            }

            if (configFieldControl != null)
            {
                this.fieldControl = configFieldControl;
            }

            if (configFilter != null)
            {
                this.filter = configFilter;
            }
        }
        /// <summary>
        /// Builds the detail organizer pages.
        /// </summary>
        protected override void BuildDetailOrganizerPages()
        {
            UPMOrganizer detailOrganizer = new UPMOrganizer(StringIdentifier.IdentifierWithStringId("Documemnts"));

            detailOrganizer.ExpandFound = true;
            this.TopLevelElement        = detailOrganizer;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            string organizerColorKey            = this.ViewReference.ContextValueForKey("OrganizerColor");

            if (!string.IsNullOrEmpty(organizerColorKey))
            {
                this.Organizer.OrganizerColor = AureaColor.ColorWithString(organizerColorKey);
            }

            string         headerName = this.ViewReference.ContextValueForKey("HeaderName");
            UPConfigHeader header     = null;

            if (!string.IsNullOrEmpty(headerName))
            {
                header = configStore.HeaderByName(headerName);
            }

            detailOrganizer.SubtitleText = header != null ? header.Label : LocalizedString.TextProcessDocuments;

            this.ShouldShowTabsForSingleTab = false;
            DocumentPageModelController docPageModelController = new DocumentPageModelController(this.ViewReference);

            this.AddPageModelController(docPageModelController);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanelCell"/> class.
        /// </summary>
        /// <param name="fieldControlTab">The field control tab.</param>
        /// <param name="resultRow">The result row.</param>
        public UPSerialEntryParentInfoPanelCell(FieldControlTab fieldControlTab, UPCRMResultRow resultRow)
        {
            int           numberOfFields = fieldControlTab.NumberOfFields;
            List <string> fields         = new List <string>();

            if (!string.IsNullOrEmpty(fieldControlTab.Label))
            {
                fields.Add(fieldControlTab.Label);
            }

            for (int index = 0; index < numberOfFields; index++)
            {
                UPConfigFieldControlField field = fieldControlTab.FieldAtIndex(index);
                if (index == 0)
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                    this.ImageName = configStore.InfoAreaConfigById(field.InfoAreaId).ImageName;
                }

                int    offset = 0;
                string value  = resultRow.FormattedFieldValueAtIndex(index, offset, fieldControlTab);
                index += offset;
                if (!string.IsNullOrEmpty(value))
                {
                    fields.Add(value);
                }
            }

            this.FieldValues = fields;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSEPricingSet"/> class.
        /// </summary>
        /// <param name="configName">Name of the configuration.</param>
        /// <param name="scaleConfigName">Name of the scale configuration.</param>
        /// <param name="bundleConfigName">Name of the bundle configuration.</param>
        /// <param name="bundleScaleConfigName">Name of the bundle scale configuration.</param>
        /// <param name="pricing">The pricing.</param>
        /// <param name="theDelegate">The delegate.</param>
        public UPSEPricingSet(string configName, string scaleConfigName, string bundleConfigName, string bundleScaleConfigName,
                              UPSEPricing pricing, UPSEPricingSetDelegate theDelegate)
        {
            this.fastRequest = ServerSession.CurrentSession.IsEnterprise;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            this.ConfigSearchAndList = configStore.SearchAndListByName(configName);
            this.ConfigFieldControl  = this.ConfigSearchAndList != null?configStore.FieldControlByNameFromGroup("List", this.ConfigSearchAndList.FieldGroupName) : null;

            if (this.ConfigFieldControl == null)
            {
                throw new InvalidOperationException("ConfigFieldControl is null");
            }

            this.TheDelegate = theDelegate;
            this.Pricing     = pricing;
            if (!string.IsNullOrEmpty(scaleConfigName))
            {
                this.ScaleConfigSearchAndList = configStore.SearchAndListByName(scaleConfigName);
                this.ScaleConfigFieldControl  = this.ScaleConfigSearchAndList != null?configStore.FieldControlByNameFromGroup("List", this.ScaleConfigSearchAndList.FieldGroupName) : null;
            }

            if (!string.IsNullOrEmpty(bundleConfigName))
            {
                this.BundleConfigSearchAndList = configStore.SearchAndListByName(bundleConfigName);
                this.BundleConfigFieldControl  = this.BundleConfigSearchAndList != null?configStore.FieldControlByNameFromGroup("List", this.BundleConfigSearchAndList.FieldGroupName) : null;

                if (!string.IsNullOrEmpty(bundleScaleConfigName))
                {
                    this.BundleScaleConfigSearchAndList = configStore.SearchAndListByName(bundleScaleConfigName);
                    this.BundleScaleConfigFieldControl  = this.BundleScaleConfigSearchAndList != null?configStore.FieldControlByNameFromGroup("List", this.BundleScaleConfigSearchAndList.FieldGroupName) : null;
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Builds the pages from view reference.
        /// </summary>
        public override void BuildPagesFromViewReference()
        {
            UPMOrganizer detailOrganizer = new UPMOrganizer(StringIdentifier.IdentifierWithStringId("History"));

            this.TopLevelElement        = detailOrganizer;
            detailOrganizer.ExpandFound = true;
            string organizerColorKey = this.ViewReference.ContextValueForKey("OrganizerColor");

            if (!string.IsNullOrEmpty(organizerColorKey))
            {
                this.Organizer.OrganizerColor = AureaColor.ColorWithString(organizerColorKey);
            }

            string headerName              = this.ViewReference.ContextValueForKey("HeaderName");
            IConfigurationUnitStore store  = ConfigurationUnitStore.DefaultStore;
            UPConfigHeader          header = store.HeaderByName(headerName);

            if (!string.IsNullOrEmpty(header.Label))
            {
                detailOrganizer.TitleText = header.Label;
            }

            this.ShouldShowTabsForSingleTab = false;
            UPHistorySearchPageModelController docPageModelController = new UPHistorySearchPageModelController(this.ViewReference);

            this.AddPageModelController(docPageModelController);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPWebContentPageModelController"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        public UPWebContentPageModelController(ViewReference viewReference)
            : base(viewReference)
        {
            this.SendByEmailActions       = new List <Menu>();
            this.SendByEmailButtonIsShown = viewReference.ContextValueIsSet("SendByEmail");
            var actionStr = viewReference.ContextValueForKey("SendByEmailAction");
            var actions   = !string.IsNullOrEmpty(viewReference.ContextValueForKey("SendByEmailAction")) ? actionStr.Split(',') : new string[0];
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            foreach (string action in actions)
            {
                Menu menu = configStore.MenuByName(action);
                if (menu != null)
                {
                    this.SendByEmailActions.Add(menu);
                }
            }

            this.WebContentMetadata = UPWebContentMetadata.WebContentMetaDataFromReportType(viewReference.ContextValueForKey("ReportType"), this);
            this.WebContentMetadata.UpdateMetadataWithViewReference(this.ViewReference);
            this.AllowsXMLExport      = this.WebContentMetadata.AllowsXMLExport;
            this.AllowsFullScreen     = this.WebContentMetadata.AllowsFullScreen;
            this.RecordIdentification = viewReference.ContextValueForKey("RecordId");
            IIdentifier       identifier = this.BuildIdentifier();
            UPMWebContentPage page       = new UPMWebContentPage(identifier)
            {
                Invalid      = true,
                PrintEnabled = this.ViewReference.ContextValueForKey("ButtonPrint") == "true"
            };

            this.TopLevelElement           = page;
            this.WebContentPage.ReportType = this.WebContentMetadata.ReportType;
            this.ApplyLoadingStatusOnPage(page);
        }
        /// <summary>
        /// Loads the specified request option.
        /// </summary>
        /// <param name="requestOption">The request option.</param>
        /// <param name="currencyDelegate">The currency delegate.</param>
        /// <returns></returns>
        public bool Load(UPRequestOption requestOption, ICurrencyConversionDelegate currencyDelegate)
        {
            if (this.CurrencyDelegate != null)
            {
                return(false);
            }

            this.CurrencyDelegate = currencyDelegate;
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(this.SearchAndListConfigName);
            UPConfigFilter          filter        = null;

            if (searchAndList != null)
            {
                filter = configStore.FilterByName(searchAndList.FilterName);
            }

            this.fieldControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);
            if (this.fieldControl != null)
            {
                this.crmQuery = new UPContainerMetaInfo(this.fieldControl, filter, null);
            }

            if (this.crmQuery == null)
            {
                this.CurrencyDelegate = null;
                this.crmQuery         = null;
                currencyDelegate.CurrencyConversionDidFailWithError(this, new Exception($"invalid searchAndList configuration {this.SearchAndListConfigName}"));
                return(true);
            }

            this.crmQuery.Find(requestOption, this);
            return(true);
        }
Esempio n. 13
0
        /// <summary>
        /// Internal method to create a Page Instance
        /// </summary>
        /// <param name="configStore">
        /// IConfigurationUnitStore
        /// </param>
        /// <param name="searchType">
        /// SearchPageSearchType
        /// </param>
        /// <returns>
        /// UPMSearchPage
        /// </returns>
        private UPMSearchPage CreatePageInstanceWorker(IConfigurationUnitStore configStore, SearchPageSearchType searchType)
        {
            var defaultRadiusMeter = 100;
            var defaultRadius      = ViewReference.ContextValueForKey("DefaultRadius");

            if (!string.IsNullOrWhiteSpace(defaultRadius))
            {
                defaultRadiusMeter = defaultRadius.ToInt();
            }

            usedFilters = new Dictionary <string, UPMFilter>();
            var identifiers = new List <IIdentifier>();
            var filters     = new List <UPMFilter>();

            PopulatePageFilterAndIdentifierLists(configStore, filters, identifiers, defaultRadiusMeter);

            var multipleIdentifier = new MultipleIdentifier(identifiers);
            var page = new UPMSearchPage(multipleIdentifier)
            {
                SearchType            = searchType,
                AvailableFilters      = filters,
                Style                 = UPMTableStyle.UPMStandardTableStyle,
                AvailableOnlineSearch = !ViewReference.ContextValueIsSet("hideOnlineOfflineButton")
            };

            return(page);
        }
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(this.SearchAndListConfigName);
            UPConfigFilter          filter        = null;

            if (searchAndList != null)
            {
                filter = configStore.FilterByName(searchAndList.FilterName);
            }

            if (searchAndList == null)
            {
                return(false);
            }

            this.fieldControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);
            if (this.fieldControl != null)
            {
                this.crmQuery = new UPContainerMetaInfo(this.fieldControl, filter, null);
            }

            if (this.crmQuery == null)
            {
                return(false);
            }

            var result = this.crmQuery.Find();

            this.HandleResult(result);
            return(true);
        }
        /// <summary>
        /// Builds the page.
        /// </summary>
        protected override void BuildPage()
        {
            base.BuildPage();
            this.ConfigName = this.ViewReference.ContextValueForKey("RootNodeConfigName");
            UPMCircleOfInfluencePage page       = this.CreatePageInstance();
            string rootNodeFieldGroup           = null;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (!string.IsNullOrEmpty(this.ConfigName))
            {
                SearchAndList searchAndList = configStore.SearchAndListByName(this.ConfigName);
                rootNodeFieldGroup = searchAndList.FieldGroupName;
            }

            if (string.IsNullOrEmpty(rootNodeFieldGroup))
            {
                rootNodeFieldGroup = this.ViewReference.ContextValueForKey("RootNodeFieldGroup");
            }

            FieldControl details     = configStore.FieldControlByNameFromGroup("Details", rootNodeFieldGroup);
            FieldControl miniDetails = configStore.FieldControlByNameFromGroup("MiniDetails", rootNodeFieldGroup);

            this.rootNodeFieldControl = new FieldControl(new List <FieldControl> {
                details, miniDetails
            });
            this.ApplyViewConfigOnPage(page);
            this.ApplyLoadingStatusOnPage(page);
            page.Invalid         = true;
            this.TopLevelElement = page;
        }
        /// <summary>
        /// Builds the page.
        /// </summary>
        public override void BuildPage()
        {
            string layoutName = this.ViewReference.ContextValueForKey("LayoutName");
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            WebConfigLayout         layout      = configStore.WebConfigLayoutByName(layoutName);

            if (layout == null)
            {
                return;
            }

            MDetailPage page = new MDetailPage(StringIdentifier.IdentifierWithStringId("Configuration"));

            page.LabelText       = LocalizedString.TextTabOverview;
            page.Invalid         = true;
            this.TopLevelElement = page;
            int tabCount = layout.TabCount;

            for (int i = 0; i < tabCount; i++)
            {
                UPGroupModelController groupModelController = UPGroupModelController.SettingsGroupModelController(layout, i);
                if (groupModelController != null)
                {
                    this.GroupModelControllerArray.Add(groupModelController);
                }
            }
        }
        /// <summary>
        /// Processes the json response.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <param name="remoteData">The remote data.</param>
        public override void ProcessJsonResponse(Dictionary <string, object> json, RemoteData remoteData)
        {
            object statusInfo = json.ValueOrDefault("StatusInfo");

            if (statusInfo != null)
            {
                Exception error = this.HandleStatusInfo(statusInfo);
                if (error != null)
                {
                    this.ProcessErrorWithRemoteData(error, remoteData);
                    return;
                }
            }

            object updatedWebConfigurationValues = json.ValueOrDefault("WebConfigValue");

            if (updatedWebConfigurationValues != null)
            {
                IConfigurationUnitStore configStore       = ConfigurationUnitStore.DefaultStore;
                UPSyncConfiguration     syncConfiguration = new UPSyncConfiguration(configStore);
                //syncConfiguration.SyncElementsOfUnitType(updatedWebConfigurationValues, "WebConfigValue", true);
                configStore.Reset();
                ServerSession.CurrentSession.LoadApplicationSettings();
            }

            this.TheDelegate.ChangeConfigurationRequestDidFinishWithResult(this, null);
        }
        /// <summary>
        /// Creates the specified definition.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <param name="serialEntry">The serial entry.</param>
        /// <returns></returns>
        public static UPSerialEntrySourceRowInfo Create(Dictionary <string, string> definition, UPSerialEntry serialEntry)
        {
            string name = definition.ValueOrDefault("name");

            if (name == null)
            {
                return(null);
            }

            var newObj = new UPSerialEntrySourceRowInfo(name, serialEntry);

            newObj.VerticalRows = false;

            string configName = definition.ValueOrDefault("configName") ?? name;
            string parameters = definition.ValueOrDefault("maxResults");

            newObj.MaxResults         = !string.IsNullOrEmpty(parameters) ? Convert.ToInt32(parameters) : 10;
            newObj.IgnoreSourceRecord = Convert.ToInt32(definition.ValueOrDefault("NoLink")) != 0;

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            newObj.SearchAndList = configStore.SearchAndListByName(configName);
            if (newObj.SearchAndList == null)
            {
                return(null);
            }

            newObj.FieldControl = configStore.FieldControlByNameFromGroup("List", newObj.SearchAndList.FieldGroupName);
            if (newObj.FieldControl == null)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(newObj.SearchAndList.FilterName))
            {
                newObj.Filter = configStore.FilterByName(newObj.SearchAndList.FilterName);
                if (!string.IsNullOrEmpty(newObj.Filter?.DisplayName))
                {
                    newObj.Label = newObj.Filter.DisplayName;
                }
            }

            List <string> columnNameArray = new List <string>();
            List <UPConfigFieldControlField> columnDefArray = new List <UPConfigFieldControlField>();

            foreach (FieldControlTab tab in newObj.FieldControl.Tabs)
            {
                foreach (UPConfigFieldControlField field in tab.Fields)
                {
                    columnDefArray.Add(field);
                    columnNameArray.Add(field.Label);
                }
            }

            newObj.ColumnDefs  = columnDefArray;
            newObj.ColumnNames = columnNameArray;

            return(newObj);
        }
        /// <summary>
        /// Filters for configuration filter.
        /// </summary>
        /// <param name="configFilter">The configuration filter.</param>
        /// <param name="searchAndListName">Name of the search and list.</param>
        /// <param name="filterParameters">The filter parameters.</param>
        /// <param name="singleSelect">if set to <c>true</c> [single select].</param>
        /// /// <returns>Filter</returns>
        public static UPMFilter FilterForConfigFilter(UPConfigFilter configFilter, string searchAndListName, Dictionary <string, object> filterParameters, bool singleSelect)
        {
            if (string.IsNullOrEmpty(searchAndListName))
            {
                return(null);
            }

            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(searchAndListName);

            if (searchAndList != null)
            {
                return(null);
            }

            FieldControl listControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);

            if (listControl == null)
            {
                return(null);
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(searchAndListName, filterParameters);

            UPCRMResult result = crmQuery.Find();
            int         count  = result.RowCount;

            if (count == 0)
            {
                return(null);
            }

            UPCRMListFormatter                  listFormatter = new UPCRMListFormatter(listControl.TabAtIndex(0));
            StringIdentifier                    identifier    = StringIdentifier.IdentifierWithStringId("SelectFilter");
            UPMSelectCatalogFilter              filter        = new UPMSelectCatalogFilter(identifier);
            Dictionary <string, string>         dict          = new Dictionary <string, string>(count);
            Dictionary <string, UPCRMResultRow> rowDict       = new Dictionary <string, UPCRMResultRow>(count);

            for (int i = 0; i < count; i++)
            {
                UPCRMResultRow row        = (UPCRMResultRow)result.ResultRowAtIndex(i);
                string         fieldValue = listFormatter.StringFromRowForPosition(row, 0);
                dict[row.RootRecordIdentification]    = fieldValue;
                rowDict[row.RootRecordIdentification] = row;
            }

            filter.CrmResult             = result;
            filter.FilterParameters      = filterParameters;
            filter.ResultRowDictionary   = rowDict;
            filter.ExplicitCatalogValues = dict;
            filter.ParameterName         = "Select";
            filter.Name = configFilter.UnitName;

            filter.DisplayName = !string.IsNullOrEmpty(configFilter.DisplayName) ? configFilter.DisplayName : configFilter.UnitName;

            filter.SingleSelect = singleSelect;
            return(filter);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditChildrenGroupModelController"/> class.
        /// </summary>
        /// <param name="fieldControl">The field control.</param>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="editPageContext">The edit page context.</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <exception cref="Exception">
        /// TabConfig is null
        /// or
        /// ChildFieldControl is null
        /// </exception>
        public EditChildrenGroupModelController(FieldControl fieldControl, int tabIndex, UPEditPageContext editPageContext, IGroupModelControllerDelegate theDelegate)
            : base(fieldControl, tabIndex, editPageContext, theDelegate)
        {
            FieldControlTab tabConfig = fieldControl.TabAtIndex(tabIndex);

            if (tabConfig == null)
            {
                throw new Exception("TabConfig is null");
            }

            var typeParts = tabConfig.Type.Split('_');

            if (typeParts.Length > 1)
            {
                string detailsConfigurationName = (string)typeParts[1];
                var    configNameParts          = detailsConfigurationName.Split('#');
                if (configNameParts.Length > 1)
                {
                    this.LinkId = Convert.ToInt32(configNameParts[1]);
                    detailsConfigurationName = configNameParts[0];
                }

                IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                this.ChildFieldControl = configStore.FieldControlByNameFromGroup("Edit", detailsConfigurationName);
                if (this.ChildFieldControl.NumberOfTabs > 1)
                {
                    this.ChildFieldControl = this.ChildFieldControl.FieldControlWithSingleTab(0);
                }

                this.ChildInfoAreaId = this.ChildFieldControl.InfoAreaId;
                if (typeParts.Length > 2)
                {
                    UPConfigFilter templateFilter = configStore.FilterByName((string)typeParts[2]);
                    if (templateFilter != null)
                    {
                        templateFilter     = templateFilter.FilterByApplyingReplacements(UPConditionValueReplacement.DefaultParameters);
                        this.initialValues = templateFilter.FieldsWithConditions(false);
                    }
                }
            }
            else if (tabConfig.NumberOfFields > 0)
            {
                UPConfigFieldControlField childField = tabConfig.FieldAtIndex(0);
                this.ChildInfoAreaId   = childField.InfoAreaId;
                this.LinkId            = childField.LinkId;
                this.ChildFieldControl = fieldControl.FieldControlWithSingleTabRootInfoAreaIdRootLinkId(tabIndex, this.ChildInfoAreaId, this.LinkId);
            }
            else
            {
                this.ChildFieldControl = null;
            }

            if (this.ChildFieldControl == null)
            {
                throw new Exception("ChildFieldControl is null");
            }
        }
        /// <summary>
        /// Builds the detail organizer pages.
        /// </summary>
        public void BuildDetailOrganizerPages()
        {
            UPMOrganizer detailOrganizer = new UPMOrganizer(StringIdentifier.IdentifierWithStringId("Details"));

            this.TopLevelElement        = detailOrganizer;
            detailOrganizer.ExpandFound = true;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            string          configName          = this.ViewReference.ContextValueForKey("LayoutName");
            WebConfigLayout layout = configStore.WebConfigLayoutByName(configName);

            if (layout == null)
            {
                return;
            }

            string organizerColorKey = this.ViewReference.ContextValueForKey("OrganizerColor");

            if (!string.IsNullOrEmpty(organizerColorKey))
            {
                this.Organizer.OrganizerColor = AureaColor.ColorWithString(organizerColorKey);
            }

            string         headerName = this.ViewReference.ContextValueForKey("HeaderName");
            UPConfigHeader header     = null;

            if (!string.IsNullOrEmpty(headerName))
            {
                header = configStore.HeaderByName(headerName);
            }

            if (header == null)
            {
                headerName = "SYSTEMINFO.Expand";
                header     = configStore.HeaderByName(headerName);
            }

            if (header != null)
            {
                detailOrganizer.SubtitleText = header.Label;
                this.AddActionButtonsFromHeaderRecordIdentification(header, null);
            }
            else
            {
                detailOrganizer.SubtitleText = LocalizedString.TextSettings;
                UPMOrganizerAction action = new UPMOrganizerAction(StringIdentifier.IdentifierWithStringId("action.edit"));
                action.SetTargetAction(this, this.SwitchToEdit);
                action.LabelText = LocalizedString.TextEdit;
                action.IconName  = "Button:Edit";
                this.AddOrganizerHeaderActionItem(action);
            }

            SettingsViewPageModelController detailPageModelController = new SettingsViewPageModelController(this.ViewReference);
            Page overviewPage = detailPageModelController.Page;

            this.AddPageModelController(detailPageModelController);
            detailOrganizer.AddPage(overviewPage);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPSyncDataSets"/> class.
 /// </summary>
 /// <param name="session">
 /// The session.
 /// </param>
 /// <param name="incremental">
 /// if set to <c>true</c> [incremental].
 /// </param>
 /// <param name="crmDataStore">
 /// The CRM data store.
 /// </param>
 /// <param name="configStore">
 /// The configuration store.
 /// </param>
 /// <param name="theDelegate">
 /// The delegate.
 /// </param>
 public UPSyncDataSets(
     IServerSession session,
     bool incremental,
     ICRMDataStore crmDataStore,
     IConfigurationUnitStore configStore,
     ISyncDataSetsDelegate theDelegate)
     : this(configStore?.AllDataSetNamesSorted(), incremental, session, crmDataStore, configStore, theDelegate)
 {
 }
        /// <summary>
        /// The buttons for result row.
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public List <UPConfigButton> ButtonsForResultRow(UPCRMResultRow row)
        {
            UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row);

            if (matchingTable != null)
            {
                List <UPConfigButton> matchingButtons = new List <UPConfigButton>();

                UPConfigQueryCondition propertyCondition = matchingTable.PropertyConditions[@"Action"];

                if (propertyCondition != null)
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

                    foreach (string menuName in propertyCondition.FieldValues)
                    {
                        Menu menu = configStore.MenuByName(menuName);
                        if (menu != null)
                        {
                            UPConfigButton button = new UPConfigButton(
                                menu.DisplayName,
                                menu.ImageName,
                                menu.ViewReference);
                            matchingButtons.Add(button);
                        }
                        else if (menuName.StartsWith(@"Button:"))
                        {
                            UPConfigButton button = configStore.ButtonByName(menuName.Substring(7));
                            if (button != null)
                            {
                                matchingButtons.Add(button);
                            }
                        }
                    }
                }

                propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("ButtonAction");

                if (propertyCondition != null)
                {
                    foreach (string buttonName in propertyCondition.FieldValues)
                    {
                        UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName);

                        if (button != null)
                        {
                            matchingButtons.Add(button);
                        }
                    }
                }

                return(matchingButtons.Count > 0 ? matchingButtons : null);
            }

            return(null);
        }
Esempio n. 24
0
        /// <summary>
        /// Populates filters and Identifiers for Page
        /// </summary>
        /// <param name="configStore">
        /// IConfigurationUnitStore
        /// </param>
        /// <param name="filters">
        /// List&lt;UPMFilter&gt;
        /// </param>
        /// <param name="identifiers">
        /// List&lt;IIdentifier&gt;
        /// </param>
        /// <param name="defaultRadiusMeter">
        /// defaultRadiusMeter
        /// </param>
        private void PopulatePageFilterAndIdentifierLists(
            IConfigurationUnitStore configStore,
            List <UPMFilter> filters,
            List <IIdentifier> identifiers,
            int defaultRadiusMeter)
        {
            PopulatePageFiltersAndIdentifiersForConfig1Filter(configStore, filters, identifiers, defaultRadiusMeter);

            PopulatePageFiltersAndIdentifiersForNonConfig1Filter(configStore, filters, identifiers, defaultRadiusMeter);
        }
Esempio n. 25
0
        private void LoadItems()
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

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

                if (!string.IsNullOrEmpty(this.ItemSearchAndListControl.FilterName))
                {
                    filter = configStore.FilterByName(this.ItemSearchAndListControl.FilterName);
                    if (filter != null && this.sourceFieldDictionary != null)
                    {
                        filter = filter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary));
                    }
                }

                UPConfigFieldControlField groupField = this.ItemFieldControl.FieldWithFunction(Constants.FieldGroupString);
                UPConfigFieldControlField itemField  = this.ItemFieldControl.FieldWithFunction(Constants.FieldItemString);
                if (this.ItemFieldControl != null && groupField != null && itemField != null)
                {
                    this.crmQuery = new UPContainerMetaInfo(this.ItemFieldControl);
                    if (groupFilter != null)
                    {
                        this.crmQuery.ApplyFilter(groupFilter);
                    }

                    if (filter != null)
                    {
                        this.crmQuery.ApplyFilter(filter);
                    }

                    this.currentQueryType = 1;
                    this.crmQuery.Find(this.SourceRequestOption, this);
                }
                else
                {
                    this.HandleGroupsWithAllItems(this.Groups);
                }
            }
            else
            {
                this.HandleGroupsWithAllItems(this.Groups);
            }
        }
        /// <summary>
        /// Builds the page.
        /// </summary>
        public override void BuildPage()
        {
            this.ConfigName  = this.ViewReference.ContextValueForKey("ConfigName");
            this.ConfigTabNr = Convert.ToInt32(this.ViewReference.ContextValueForKey("ConfigTabNr"));
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            Form form = configStore.FormByName(this.ConfigName);

            this.formtab = null;
            MDashboardPage _page = (MDashboardPage)this.InstantiatePage();

            if (this.ConfigTabNr < form.NumberOfTabs)
            {
                if (this.ConfigTabNr < 0)
                {
                    this.ConfigTabNr = 0;
                }

                this.formtab = form.TabAtIndex(this.ConfigTabNr);
            }
            else
            {
                this.Logger.LogError($"Configured ConfigTabNr {this.ConfigTabNr} is larger than the number of available tabs {form.NumberOfTabs}");

                // DDLogError("Configured ConfigTabNr (%ld) is larger than the number of available tabs (%lu)", (long)this.ConfigTabNr, (unsigned long)form.NumberOfTabs());
                return;
            }

            _page.LabelText = !string.IsNullOrWhiteSpace(this.formtab.Label) ? this.formtab.Label : "*** FormTab Label Missing ***";

            _page.Invalid        = true;
            this.TopLevelElement = _page;
            string copyRecordIdentification = this.ViewReference.ContextValueForKey("RecordId");
            string copyFieldGroupName       = this.ViewReference.ContextValueForKey("CopySourceFieldGroupName");

            this.copyFields = null;

            if (copyRecordIdentification.IsRecordIdentification() && !string.IsNullOrWhiteSpace(copyFieldGroupName))
            {
                FieldControl fieldControl = configStore.FieldControlByNameFromGroup("List", copyFieldGroupName);
                if (fieldControl != null)
                {
                    this.copyFields = new UPCopyFields(fieldControl);
                }
            }

            if (this.copyFields != null)
            {
                this.copyFields.CopyFieldValuesForRecordIdentification(copyRecordIdentification, false, this);
            }
            else
            {
                this.ContinueWithCopyFields(null);
            }
        }
        /// <summary>
        /// Creates the page instance.
        /// </summary>
        /// <returns></returns>
        public override UPMSearchPage CreatePageInstance()
        {
            this.InfoAreaId = this.ViewReference.ContextValueForKey("InfoArea");
            this.ConfigName = this.ViewReference.ContextValueForKey("ConfigName");
            string searchTypeString         = this.ViewReference.ContextValueForKey("InitialSearchType");
            SearchPageSearchType searchType = SearchPageSearchType.OfflineSearch;
            string fullTextSearchString     = this.ViewReference.ContextValueForKey("FullTextSearch");

            this.FullTextSearch = !(string.IsNullOrEmpty(fullTextSearchString) || fullTextSearchString == "false");

            this.MinSearchTextLength = Convert.ToInt32(this.ViewReference.ContextValueForKey("MinSearchTextLength"));

            if (this.MinSearchTextLength == 0)
            {
                this.MinSearchTextLength = 1;
            }

            if (!string.IsNullOrEmpty(searchTypeString))
            {
                searchType = (SearchPageSearchType)Convert.ToInt32(searchTypeString);
            }

            if (string.IsNullOrEmpty(this.InfoAreaId) && this.ViewReference.ContextValueForKey("Modus") == "GlobalSearch")
            {
                if (string.IsNullOrEmpty(this.ConfigName))
                {
                    this.ConfigName = "default";
                }
            }

            List <IIdentifier>      identifiers = new List <IIdentifier>();
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            QuickSearch             quickSearch = configStore.QuickSearchByName(this.ConfigName);
            int infoAreaCount = quickSearch?.NumberOfInfoAreas ?? 0;

            for (int i = 0; i < infoAreaCount; i++)
            {
                string currentInfoAreaId = quickSearch.InfoAreaIdAtIndex(i);
                identifiers.Add(new RecordIdentifier(currentInfoAreaId, null));
            }

            MultipleIdentifier multipleIdentifier = new MultipleIdentifier(identifiers);
            UPMSearchPage      page = new UPMSearchPage(multipleIdentifier);

            page.SearchType            = searchType;
            page.AvailableOnlineSearch = !this.ViewReference.ContextValueIsSet("hideOnlineOfflineButton");
            page.Style = UPMTableStyle.UPMGlobalSearchTableStyle;
            if (searchType == SearchPageSearchType.OnlineSearch)
            {
                page.InitiallyOnline = true;
            }

            return(page);
        }
 /// <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. 29
0
        /// <summary>
        /// Adds the remaining page model controller.
        /// </summary>
        public void AddRemainingPageModelController()
        {
            this.created = true;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPConfigHeader          editHeader  = configStore.HeaderByNameFromGroup(this.IsNew ? "New" : "Update", this.ExpandConfig.HeaderGroupName) ??
                                                  configStore.HeaderByNameFromGroup("Edit", this.ExpandConfig.HeaderGroupName);

            if (editHeader != null && editHeader.SubViews.Count != 0)
            {
                Page rootPage = this.PageModelControllers[0].Page;
                if (string.IsNullOrEmpty(rootPage.LabelText) && !string.IsNullOrEmpty(editHeader.Label))
                {
                    this.PageModelControllers[0].Page.LabelText = editHeader.Label;
                }

                foreach (UPConfigHeaderSubView subView in editHeader.SubViews)
                {
                    ViewReference pageViewReference = this.CopyFieldDictionary != null
                        ? subView.ViewReference.ViewReferenceWith(new Dictionary <string, object> {
                        { "copyFields", this.CopyFieldDictionary }
                    })
                        : subView.ViewReference;

                    UPPageModelController pageModelController = pageViewReference.ViewName == "RecordView"
                        ? new EditPageModelController(pageViewReference.ViewReferenceWith(this.RecordIdentification))
                        : this.PageForViewReference(pageViewReference.ViewReferenceWith(this.RecordIdentification));

                    if (pageModelController != null)
                    {
                        if (pageModelController is SerialEntryPageModelController)
                        {
                            //pageModelController.AddObserverForKeyPathOptionsContext(this, "hasRunningChangeRequests", NSKeyValueObservingOptionNew, null);
                        }

                        pageModelController.Page.Invalid   = true;
                        pageModelController.Page.LabelText = subView.Label;
                        pageModelController.Delegate       = this;
                        this.AddPageModelController(pageModelController);
                        this.Organizer.AddPage(pageModelController.Page);

                        if (pageModelController is UPWebContentPageModelController)
                        {
                            if (((UPWebContentPageModelController)pageModelController).AllowsXMLExport)
                            {
                                UPMOrganizerAction exportXMLAction = new UPMOrganizerAction(StringIdentifier.IdentifierWithStringId("action.exportXML"));
                                //exportXMLAction.SetTargetAction(pageModelController, ExportXML);
                                exportXMLAction.LabelText = "Export XML";
                                this.AddOrganizerHeaderActionItem(exportXMLAction);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMParticipants"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        /// <param name="rootInfoAreaId">The root information area identifier.</param>
        /// <param name="linkParticipantsInfoAreaId">The link participants information area identifier.</param>
        /// <param name="linkParticipantsLinkId">The link participants link identifier.</param>
        /// <param name="recordIdentification">The record identification.</param>
        /// <param name="theDelegate">The delegate.</param>
        public UPCRMParticipants(ViewReference viewReference, string rootInfoAreaId, string linkParticipantsInfoAreaId, int linkParticipantsLinkId, string recordIdentification, UPCRMParticipantsDelegate theDelegate)
        {
            this.RecordIdentification = recordIdentification;
            this.TheDelegate          = theDelegate;

            this.RootInfoAreaId = rootInfoAreaId ?? recordIdentification.InfoAreaId();

            if (string.IsNullOrEmpty(this.RootInfoAreaId))
            {
                this.RootInfoAreaId = "MA";
            }

            this.linkParticipantsInfoAreaId = linkParticipantsInfoAreaId;
            this.linkParticipantsLinkId     = linkParticipantsLinkId;

            if (viewReference == null)
            {
                Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName($"Configuration:{this.RootInfoAreaId}Participants");
                this.ViewReference = menu?.ViewReference;
            }
            else
            {
                this.ViewReference = viewReference;
            }

            this.RepParticipantsRequestOption = UPCRMDataStore.RequestOptionFromString(this.ViewReference?.ContextValueForKey("RepAcceptanceRequestOption"), UPRequestOption.FastestAvailable);
            this.AcceptanceFieldId            = -1;
            string configName = this.ViewReference?.ContextValueForKey("RepAcceptanceConfigName");

            if (!string.IsNullOrEmpty(configName))
            {
                IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
                SearchAndList           searchAndList = configStore.SearchAndListByName(configName);

                if (!string.IsNullOrEmpty(searchAndList.FieldGroupName))
                {
                    configName = searchAndList.FieldGroupName;
                }

                FieldControl fieldControl = configStore.FieldControlByNameFromGroup("Edit", configName) ??
                                            configStore.FieldControlByNameFromGroup("List", configName);

                if (fieldControl != null)
                {
                    UPConfigFieldControlField field = fieldControl.FieldWithFunction(Constants.UPRepAcceptanceFunctionName_Acceptance);
                    if (field != null)
                    {
                        this.AcceptanceFieldId = field.FieldId;
                    }

                    this.RepAcceptanceInfoAreaId = fieldControl.InfoAreaId;
                }
            }
        }