public static string RenderFormGroupSelectElement(HtmlHelper html, SelectElementModel inputModel,
			LabelModel labelModel, InputType inputType)
        {
            HtmlString input = null;

            if (inputType == InputType.DropDownList)
                input = RenderSelectElement(html, inputModel, InputType.DropDownList);

            if (inputType == InputType.ListBox)
                input = RenderSelectElement(html, inputModel, InputType.ListBox);

            var label = RenderLabel(html, labelModel ?? new LabelModel
            {
                htmlFieldName = inputModel.htmlFieldName,
                metadata = inputModel.metadata,
                htmlAttributes = new {@class = "control-label"}.ToDictionary()
            });

            var fieldIsValid = true;

            if (inputModel != null)
                fieldIsValid = html.ViewData.ModelState.IsValidField(inputModel.htmlFieldName);

            return new FormGroup(input, label, FormGroupType.TextBoxLike, fieldIsValid).ToHtmlString();
        }
Пример #2
0
        private async Task <bool> LoadTreeItemData()
        {
            if (MainViewModel.Instance.SelectedElement == null)
            {
                return(false);
            }

            // отменяем выполняюшиеся задачи
            if (cancelTokenSource != null)
            {
                cancelTokenSource.Cancel();
            }

            await ShowProgress("Пожалуйста, подождите...", "Получение данных...");

            string data = string.Empty;

            try
            {
                bool result = await Task.Run <bool>(() =>
                {
                    /*PageResult<AllTariffsExportIndicationViewItem> pageResult = armtes.GetSmallEngineExportIndications(MainViewModel.Instance.StartDate);
                     * if (pageResult != null)
                     * {
                     *  List<AllTariffsExportIndicationViewItem> items = pageResult.Items;
                     *  if (items != null)
                     *  {
                     *      var accounts = armtes.GetPersonalAccounts();
                     *      if (accounts != null)
                     *      {
                     *          var list = accounts.Items;
                     *          var accountsReses = list.GroupBy(i => i.ResName);
                     *
                     *          var entp = armtes.GetEnterprises();
                     *          var enterprises = entp.Items;
                     *
                     *          var flat = enterprises.SelectMany(i => i.ChildEnterprises);
                     *
                     *          var fes = flat.Where(i => i.EnterpriseName == "ОЭС");
                     *          var reses = fes.SelectMany(i => i.ChildEnterprises);
                     *
                     *          foreach (var res in reses)
                     *          {
                     *              var resAccounts = accountsReses.Where(a => a.Key == res.EnterpriseName).Select(i => i.ToList()).ToList();
                     *              if (resAccounts != null && resAccounts.Count > 0)
                     *              foreach (var item in resAccounts[0])
                     *              {
                     *                  var viewitem = items.Where(i => i.PersonalAccount == item.PersonalAccount).ToList();
                     *                  if (viewitem != null)
                     *                      {
                     *                          ;
                     *                      }
                     *                  else
                     *                      {
                     *                          ;
                     *                      }
                     *              }
                     *          }
                     *
                     *      }
                     *
                     *
                     *      var c = pageResult.Count;
                     *  }
                     * }*/

                    data = armtes.SelectElement(
                        MainViewModel.Instance.SelectedElement.Value,
                        MainViewModel.Instance.StartDate,
                        MainViewModel.Instance.EndDate,
                        MainViewModel.Instance.ProfileType,
                        MainViewModel.Instance.SectorType);

                    if (String.IsNullOrEmpty(data))
                    {
                        return(false);
                    }

                    // убираем лишнее
                    data = ClearString(data);

                    SelectElementModel elementModel = null;
                    elementModel = HtmlParser.ViewElement(data, MainViewModel.Instance.SelectedElement.Value, progressController);

                    MainViewModel.Instance.Collectors = new System.Collections.ObjectModel.ObservableCollection <Collector>(elementModel.Collectors);
                    MainViewModel.Instance.Statistics = elementModel.Statistics;

                    return(true);
                });

                if (result == false)
                {
                    string errorDescription = this.GetNetErrorDescription(armtes.LastException);
                    await this.ShowErrorMessageAsync(errorDescription);

                    return(false);
                }

                MainViewModel.Instance.IsFullDataLoaded = false;

                await CloseProgress();

                cancelTokenSource = new System.Threading.CancellationTokenSource();
                cancelToken       = cancelTokenSource.Token;

                try
                {
                    // теперь обновляем информацию по всем системам
                    MainViewModel.Instance.UpdatingProcessStarted = true;
                    await Task.Factory.StartNew(() =>
                    {
                        int collectorsCount = MainViewModel.Instance.Collectors.Count;
                        string info         = "Обновляем информацию по всем системам ... {0}%";

                        int processed             = 0;
                        object sync               = new object();
                        ParallelOptions po        = new ParallelOptions();
                        po.MaxDegreeOfParallelism = 4;
                        Parallel.For(0, collectorsCount, po, (i, state) =>
                        {
                            if (state.ShouldExitCurrentIteration)
                            {
                                if (state.LowestBreakIteration < i)
                                {
                                    return;
                                }
                            }

                            if (cancelToken.IsCancellationRequested)
                            {
                                this.DebugPrint("Отмена на {0}-й системе.)", i);
                                state.Stop();
                                return;
                            }

                            Collector collector = MainViewModel.Instance.Collectors[i];
                            data = String.Empty;
                            foreach (var obj in collector.Objects)
                            {
                                if (cancelToken.IsCancellationRequested)
                                {
                                    this.DebugPrint("Отмена на {0}-й системе.)", i);
                                    state.Stop();
                                    return;
                                }

                                data         = null;
                                int attempts = 1;
                                while (data == null && attempts <= 3)
                                {
                                    data = armtes.ViewObject(
                                        obj.Id,
                                        MainViewModel.Instance.SelectedElement.Value,
                                        MainViewModel.Instance.StartDate,
                                        MainViewModel.Instance.EndDate,
                                        MainViewModel.Instance.ProfileType,
                                        MainViewModel.Instance.SectorType);
                                    attempts++;
                                }
                                if (data != null)
                                {
                                    // убираем лишнее
                                    data = ClearString(data);

                                    ViewDeviceModel viewDeviceModel = HtmlParser.ViewDevice(data, null);

                                    if (viewDeviceModel != null)
                                    {
                                        obj.ViewModel = viewDeviceModel;
                                    }

                                    foreach (var counter in obj.Counters)
                                    {
                                        if (cancelToken.IsCancellationRequested)
                                        {
                                            this.DebugPrint("Отмена на {0}-й системе.)", i);
                                            state.Stop();
                                            return;
                                        }

                                        data     = null;
                                        attempts = 1;
                                        while (data == null && attempts <= 3)
                                        {
                                            data = armtes.ViewMeter(
                                                counter.Id,
                                                MainViewModel.Instance.SelectedElement.Value,
                                                counter.ParentId,
                                                MainViewModel.Instance.StartDate,
                                                MainViewModel.Instance.EndDate,
                                                MainViewModel.Instance.ProfileType,
                                                MainViewModel.Instance.SectorType);
                                            attempts++;
                                        }
                                        if (data == null)
                                        {
                                            continue;
                                        }

                                        // убираем лишнее
                                        data = ClearString(data);

                                        ViewCounterModel vm = HtmlParser.ViewCounter(data, progressController);

                                        counter.ViewModel = vm;

                                        counter.PreviousIndications = vm.IndicationViewItem.PreviousIndications;
                                        counter.NextIndications     = vm.IndicationViewItem.NextIndications;
                                    }
                                }
                            }
                            lock (sync)
                            {
                                processed++;
                                Dispatcher.BeginInvoke(new Action(() => SetAppStatus(String.Format(info, 100 * processed / collectorsCount))), System.Windows.Threading.DispatcherPriority.Send);
                            }
                        });
                    }, cancelTokenSource.Token)
                    .ContinueWith((_) =>
                    {
                        DebugPrint("Обновление информации по системам завершено.");

                        MainViewModel.Instance.IsFullDataLoaded       = true;
                        MainViewModel.Instance.UpdatingProcessStarted = false;
                        SetAppStatus();

                        if (cancelTokenSource != null)
                        {
                            cancelTokenSource.Dispose();
                        }
                        cancelTokenSource = null;

                        MainViewModel.Instance.FilteredCollectors.Refresh();

                        return(true);
                    });
                }
                catch (OperationCanceledException)
                {
                    cancelTokenSource.Cancel();
                    MainViewModel.Instance.ShowMessage("Операция отменена.", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (AggregateException ae)
                {
                    cancelTokenSource.Cancel();
                    foreach (Exception exception in ae.InnerExceptions)
                    {
                        if (exception is TaskCanceledException)
                        {
                            this.ShowErrorMessage(String.Format("Возникла ошибка!\nException: {0}", ((TaskCanceledException)exception).Message));
                        }
                        else
                        {
                            this.ShowErrorMessage("Возникла ошибка!\nException: " + exception.GetType().Name);
                        }
                    }
                    cancelTokenSource = null;
                }
            }
            catch (Exception ex)
            {
                cancelTokenSource.Cancel();
                cancelTokenSource = null;
                this.ShowErrorMessage(ex.Message);
            }
            return(true);
        }
Пример #3
0
        public static SelectElementModel ViewElement(string data, string parentId, ProgressDialogController progressController)
        {
            //Debug.Assert(String.IsNullOrEmpty(data), "data is empty!");

            SelectElementModel result = new SelectElementModel();

            //data = System.IO.File.ReadAllText("data");

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(data);

            if (doc.DocumentNode.ChildNodes.Count > 1)
            {
                HtmlAgilityPack.HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//div[@id='collectorsDiv']/table/tbody/tr");

                if (null != nodes)
                {
                    HtmlAgilityPack.HtmlNode           row;
                    HtmlAgilityPack.HtmlNodeCollection fields;

                    bool nextIsObject  = false;
                    bool nextIsCounter = false;
                    int  startIndex    = 0;
                    int  toProcessRows = 0;

                    HtmlNode td;
                    HtmlNode img;
                    string   text;

                    int collectorId = 1;

                    try
                    {
                        result.Collectors = new List <Collector>();

                        // количество точек
                        int pointsCount = nodes.Count;
                        if (progressController != null)
                        {
                            progressController.SetMessage(String.Format("Найдено {0} расчётных точек. Получение данных...", nodes.Count));
                        }

                        double progress = 0.0d;

                        int globalRowIndex = 0;
                        while (globalRowIndex < nodes.Count)
                        {
                            row    = nodes[globalRowIndex];
                            fields = row.SelectNodes("td");

                            toProcessRows = 1;
                            if (fields[0].HasAttributes && fields[0].Attributes["rowspan"] != null)
                            {
                                Int32.TryParse(fields[0].Attributes["rowspan"].Value, out toProcessRows);
                            }

                            Collector collector = new Collector();
                            try
                            {
                                #region разбор системы

                                collector.Id = collectorId.ToString();
                                collectorId++;

                                // статус модема
                                td = fields[0];
                                if (td.ChildNodes["img"] != null)
                                {
                                    img = td.ChildNodes["img"];
                                    if (img.Attributes["src"] != null)
                                    {
                                        if (img.Attributes["src"].Value.Contains("не отвечает"))
                                        {
                                            collector.IsAnswered = false;
                                        }
                                        else
                                        {
                                            collector.IsAnswered = true;
                                        }
                                    }
                                }

                                // это УСПД
                                td = fields[1];
                                if (td.HasChildNodes && td.ChildNodes["img"] != null)
                                {
                                    collector.IsUSPD = true;
                                    img = td.ChildNodes["img"];
                                    if (img.Attributes["src"] != null)
                                    {
                                        if (img.Attributes["src"].Value.Contains("не отвечает"))
                                        {
                                            collector.IsAnsweredUSPD = false;
                                        }
                                        else
                                        {
                                            collector.IsAnsweredUSPD = true;
                                        }
                                    }
                                }
                                else
                                {
                                    collector.IsUSPD = false;
                                }

                                // УСПД сетевой адрес
                                td   = fields[2];
                                text = td.InnerText;
                                byte bvalue;
                                Byte.TryParse(text, out bvalue);
                                collector.NetworkAddress = bvalue;

                                // номер GSM - PhoneNumberColumn
                                td   = fields[3];
                                text = td.InnerText;
                                collector.PhoneNumber = text;

                                #endregion
                            }
                            catch (Exception e)
                            {
                                throw e;
                            }
                            nextIsObject = true;

                            int processedRows = 0;
                            while (processedRows < toProcessRows)
                            {
                                row        = nodes[globalRowIndex];
                                fields     = row.SelectNodes("td");
                                startIndex = nextIsObject ? 4 : 0;

                                int countersCount = 1;
                                if (fields[startIndex].HasAttributes && fields[startIndex].Attributes["rowspan"] != null)
                                {
                                    Int32.TryParse(fields[startIndex].Attributes["rowspan"].Value, out countersCount);
                                }
                                AccountingObject accountingObject = new AccountingObject();
                                try
                                {
                                    #region разбор объекта

                                    // населенный пункт - CityColumn
                                    td   = fields[startIndex++];
                                    text = td.InnerText;
                                    accountingObject.City = text;

                                    // № договора - ContractColumn
                                    td   = fields[startIndex++];
                                    text = td.InnerText;
                                    accountingObject.Contract = text;

                                    // Наименование абонента - SubscriberColumn
                                    td   = fields[startIndex++];
                                    text = td.InnerText;
                                    accountingObject.Subscriber = text;

                                    // Объект учета - ObjectColumn
                                    td   = fields[startIndex++];
                                    text = td.InnerText;
                                    accountingObject.Name = text;

                                    // Номер ТП - TpColumn
                                    td   = fields[startIndex++];
                                    text = td.InnerText;
                                    accountingObject.Tp = text;

                                    if (td.Attributes["onclick"] != null)
                                    {
                                        string link = td.Attributes["onclick"].Value;

                                        string[] linkParts = link.Split(new char[] { '(', ',', ')' });

                                        if (linkParts.Length != 4)
                                        {
                                            throw new ArgumentException("Не удалось разобрать ссылку объекта.");
                                        }

                                        string deviceId          = linkParts[1];
                                        string selectedElementId = linkParts[2].Trim(new char[] { '\'', '\'' });


                                        accountingObject.TpLink = link;
                                        accountingObject.Id     = deviceId;
                                    }
                                    else
                                    {
                                        Debugger.Break();
                                    }

                                    #endregion
                                }
                                catch (Exception e)
                                {
                                    throw e;
                                }
                                nextIsCounter = true;
                                for (int k = 0; k < countersCount; k++)
                                {
                                    row           = nodes[globalRowIndex];
                                    fields        = row.SelectNodes("td");
                                    startIndex    = nextIsObject ? 9 : (nextIsCounter ? 5 : 0);
                                    nextIsObject  = false;
                                    nextIsCounter = false;

                                    try
                                    {
                                        #region разбор учёта
                                        Counter counter = new Counter();
                                        long    lvalue  = 0;
                                        // статус счётчика
                                        td = fields[startIndex++];
                                        if (td.ChildNodes["img"] != null)
                                        {
                                            img = td.ChildNodes["img"];
                                            if (img.Attributes["src"] != null)
                                            {
                                                if (img.Attributes["src"].Value.Contains("не отвечает"))
                                                {
                                                    counter.IsAnswered = false;
                                                }
                                                else
                                                {
                                                    counter.IsAnswered = true;
                                                }
                                                if (img.Attributes["src"].Value.Contains("wrongSettings"))
                                                {
                                                    counter.HasWrongSettings = true;
                                                }
                                                else
                                                {
                                                    counter.HasWrongSettings = false;
                                                }
                                            }
                                            counter.AmperPointId = img.Attributes["alt"].Value;

                                            string link = td.Attributes["onclick"].Value;

                                            if (string.IsNullOrEmpty(link))
                                            {
                                                Debugger.Break();
                                            }

                                            string[] linkParts = link.Split(new char[] { '(', ',', ')' });

                                            if (linkParts.Length != 4)
                                            {
                                                System.Diagnostics.Debugger.Break();
                                            }

                                            string counterId         = linkParts[1];
                                            string selectedElementId = linkParts[2].Trim(new char[] { '\'', '\'' });

                                            counter.Id          = counterId;
                                            counter.CounterLink = link;
                                        }

                                        // Расчётная точка
                                        td   = fields[startIndex++];
                                        text = td.InnerText;
                                        counter.AccountingPoint = text;
                                        if (td.HasAttributes && td.Attributes["class"] != null)
                                        {
                                            if (td.Attributes["class"].Value.Contains("noPersonalAccount"))
                                            {
                                                counter.MissingPersonalAccount = true;
                                            }
                                            else
                                            {
                                                counter.MissingPersonalAccount = false;
                                            }
                                        }

                                        // тип
                                        td   = fields[startIndex++];
                                        text = td.InnerText;
                                        counter.CounterType = text;

                                        // сетевой аддрес
                                        td   = fields[startIndex++];
                                        text = td.InnerText;
                                        counter.CounterNetworkAdress = text;

                                        // заводской номер
                                        td   = fields[startIndex++];
                                        text = td.InnerText;
                                        counter.SerialNumber = text;

                                        // предыдущие показания
                                        td     = fields[startIndex++];
                                        text   = td.InnerText;
                                        lvalue = 0;
                                        long.TryParse(text, out lvalue);
                                        counter.PreviousIndication = String.IsNullOrWhiteSpace(text) ? new Nullable <long>() : lvalue;

                                        counter.PreviousIndications          = new Indications();
                                        counter.PreviousIndications.Tarriff0 = GetIndication(text);

                                        // текущие показания
                                        td     = fields[startIndex++];
                                        text   = td.InnerText;
                                        lvalue = 0;
                                        long.TryParse(text, out lvalue);
                                        counter.NextIndication = String.IsNullOrWhiteSpace(text) ? new Nullable <long>() : lvalue;

                                        counter.NextIndications          = new Indications();
                                        counter.NextIndications.Tarriff0 = GetIndication(text);

                                        // разница
                                        td     = fields[startIndex++];
                                        text   = td.InnerText;
                                        lvalue = 0;
                                        long.TryParse(text, out lvalue);
                                        counter.Difference = String.IsNullOrWhiteSpace(text) ? new Nullable <long>() : lvalue;

                                        #endregion

                                        accountingObject.Counters.Add(counter);
                                    }
                                    catch (Exception e)
                                    {
                                        throw e;
                                    }
                                    processedRows++;
                                    globalRowIndex++;

                                    progress = (double)globalRowIndex / pointsCount;
                                    if (progressController != null)
                                    {
                                        progressController.SetProgress(progress);
                                    }
                                }
                                collector.Objects.Add(accountingObject);
                            }
                            result.Collectors.Add(collector);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new ArgumentOutOfRangeException("Ошибка разбора данных: структура данных информации об объекте изменилась.\r\nОбратитесь к разработчику.", e);
                    }
                }
                // статистика
                nodes = doc.DocumentNode.SelectNodes("/div/div/div/table/tbody/tr");

                if (null != nodes)
                {
                    Statistics statistics = new Statistics();

                    HtmlNode td;
                    string   text;
                    int      value = 0;

                    #region  азбор данных

                    // Всего модемов
                    td   = nodes[0].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.ModemsCount = Int32.TryParse(text, out value) ? value : 0;

                    // Отвечающих модемов
                    td   = nodes[1].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.AnsweredModemsCount = Int32.TryParse(text, out value) ? value : 0;

                    // Не отвечающих модемов
                    td   = nodes[2].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.NotAnsweredModemsCount = Int32.TryParse(text, out value) ? value : 0;

                    // Всего УСПД
                    td   = nodes[3].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.UspdCount = Int32.TryParse(text, out value) ? value : 0;

                    // Отвечающих УСПД
                    td   = nodes[4].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.AnsweredUspdCount = Int32.TryParse(text, out value) ? value : 0;

                    // Не отвечающих УСПД
                    td   = nodes[5].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.NotAnsweredUspdCount = Int32.TryParse(text, out value) ? value : 0;

                    // Всего точек
                    td   = nodes[6].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.CountersCount = Int32.TryParse(text, out value) ? value : 0;

                    // Отвечающих счетчиков
                    td   = nodes[7].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.AnsweredCountersCount = Int32.TryParse(text, out value) ? value : 0;

                    // Не отвечающих счетчиков
                    td   = nodes[8].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.NotAnsweredCountersCount = Int32.TryParse(text, out value) ? value : 0;

                    // Недостающих данных
                    td   = nodes[9].SelectNodes("td[2]").Single();
                    text = td.InnerText;
                    statistics.MissingDataCount = Int32.TryParse(text, out value) ? value : 0;

                    #endregion

                    result.Statistics = statistics;
                }
            }
            return(result);
        }
        public static HtmlString RenderSelectElement(HtmlHelper html, SelectElementModel model, InputType inputType)
        {
            var combinedHtml = "{0}{1}{2}";
            var input = string.Empty;

            if (model.selectedValue != null)
            {
                foreach (var item in model.selectList)
                {
                    if (item.Value == model.selectedValue.ToString())
                        item.Selected = true;
                }
            }

            model.htmlAttributes.MergeHtmlAttributes(html.GetUnobtrusiveValidationAttributes(model.htmlFieldName, model.metadata));

            if (!string.IsNullOrEmpty(model.id)) model.htmlAttributes.AddOrReplace("id", model.id);

            if (model.size != Size._NotSet)
                model.htmlAttributes.AddOrMergeCssClass("class", $"input-{model.size.ToName()}");

            model.htmlAttributes.AddOrMergeCssClass("class", "form-control");

            // build html for input

            if (inputType == InputType.DropDownList)
                input =
                    html.DropDownList(model.htmlFieldName, model.selectList, model.optionLabel,
                        model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString();

            if (inputType == InputType.ListBox)
                input =
                    html.ListBox(model.htmlFieldName, model.selectList, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString();

            // account for appendString, prependString, and AppendButtons

            if (!string.IsNullOrEmpty(model.prependString) || !string.IsNullOrEmpty(model.appendString))
            {
                var appendPrependContainer = new TagBuilder("div");
                var addOn = new TagBuilder("span");

                var addOnPrependString = "";
                var addOnAppendString = "";
                var addOnPrependButtons = "";
                var addOnAppendButtons = "";

                appendPrependContainer.AddOrMergeCssClass("input-group");
                addOn.AddCssClass("input-group-addon");

                if (!string.IsNullOrEmpty(model.prependString))
                {
                    addOn.InnerHtml = model.prependString;
                    addOnPrependString = addOn.ToString();
                }

                if (!string.IsNullOrEmpty(model.appendString))
                {
                    addOn.InnerHtml = model.appendString;
                    addOnAppendString = addOn.ToString();
                }

                appendPrependContainer.InnerHtml = addOnPrependButtons + addOnPrependString + "{0}" + addOnAppendString +
                                                   addOnAppendButtons;
                combinedHtml = appendPrependContainer.ToString(TagRenderMode.Normal) + "{1}{2}";
            }

            var helpText = model.helpText != null ? model.helpText.ToHtmlString() : string.Empty;
            var validationMessage = "";

            if (model.displayValidationMessage)
            {
                var validation = html.ValidationMessage(model.htmlFieldName).ToHtmlString();
                validationMessage = new HelpText(validation, model.validationMessageStyle).ToHtmlString();
            }

            var inputElement = string.Format(combinedHtml, input, helpText, validationMessage);

            TagBuilder inputWrapper = null;

            if (!string.IsNullOrEmpty(model.inputElementWrapper))
            {
                inputWrapper = new TagBuilder(model.inputElementWrapper);

                if (model.inputElementWrapperAttributes != null)
                    inputWrapper.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(model.inputElementWrapperAttributes));

                inputWrapper.InnerHtml = inputElement;
            }

            var htmlString = inputWrapper != null
                ? inputWrapper.ToString(TagRenderMode.Normal)
                : inputElement;

            return new HtmlString(htmlString);
        }