Example #1
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
            }
        }
Example #2
0
        private void ContinueBuildPagesFromViewReference()
        {
            UPCharacteristicsEditPageModelController pageModelController = new UPCharacteristicsEditPageModelController(this.ViewReference, this.RecordIdentification, (UPOfflineCharacteristicsRequest)this.conflictEditOfflineRequest);
            UPMOrganizer organizer  = new UPMOrganizer(StringIdentifier.IdentifierWithStringId("EditCharacteristics"));
            string       infoAreaId = this.RecordIdentification.InfoAreaId();

            organizer.TitleText = LocalizedString.TextEditCharacteristics;
            UPConfigTableCaption tableCaption = ConfigurationUnitStore.DefaultStore.TableCaptionByName(this.RecordIdentification.InfoAreaId());

            organizer.TitleText = tableCaption?.TableCaptionForRecordIdentification(this.RecordIdentification);
            InfoArea infoAreaConfig = ConfigurationUnitStore.DefaultStore.InfoAreaConfigById(infoAreaId);

            organizer.SubtitleText = infoAreaConfig?.SingularName;
            if (string.IsNullOrEmpty(organizer.SubtitleText))
            {
                organizer.SubtitleText = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(infoAreaId).Label;
            }

            Page page = pageModelController.Page;

            page.LabelText = "Error";
            this.AddPageModelController(pageModelController);
            organizer.AddPage(page);
            this.TopLevelElement  = organizer;
            organizer.ExpandFound = true;
            this.AddOrganizerActions();
        }
Example #3
0
        private void GenRooms(object sender, EventArgs e) //generate rooms (button pressed)
        {
            int t;                                        //used to swap minwide and maxwide

            if (!int.TryParse(numbertries.Text, out numtries))
            {
                numtries = 5000;                                                //set number tries from form
            }
            if (!int.TryParse(minimumwidth.Text, out minwide))
            {
                minwide = 50;                                                //set minimum width from form
            }
            if (!int.TryParse(maximumwidth.Text, out maxwide))
            {
                maxwide = 100;                                                //set maximum width from form
            }
            if (maxwide < minwide)
            {
                t = minwide; minwide = maxwide; maxwide = t;
            }                                                                       //if maximum width less than minimum width, swap them
            if (!int.TryParse(spaceadded.Text, out spacer))
            {
                spacer = 50; //set spacer size from form
            }
            numrooms = 0;    //number rooms = 0
            for (int i = 0; i < maxrooms; i++)
            {
                isroom[i] = false; //clear all rooms
            }
            keepgoing = true;      //set flag to keep going
            while (keepgoing)      //while we should keep going
            {
                if (!AddRoom())
                {
                    keepgoing = false;             //if unable to add a room, clear keep going flag (stop)
                }
            }
            tunnelsizetext.Enabled = true; //Enable tunnel size text on form
            tunnelsize.Enabled     = true; //Enable tunnel size on form
            gentunnels.Enabled     = true; //Enable get tunnels button
            numtunnels             = 0;    //number tunnels = 0
            for (int i = 0; i < maxtunnels; i++)
            {
                istunnel[i] = false; //clear all tunnels
            }
            DoSort();                //sort rooms
            MapArea.Invalidate();    //redraw map area
            InfoArea.Invalidate();   //redraw info area
        }
Example #4
0
 private void comboBox_num_TextChanged(object sender, EventArgs e)
 {
     for (int i = 0; i < user.GetData().Rows.Count; i++)
     {
         if (user.GetData().Rows[i]["CarNumber"].ToString() == comboBox_num.Text)
         {
             textBox_firstName.Text = user.GetData().Rows[i]["FirstName"].ToString();
             textBox_lastName.Text  = user.GetData().Rows[i]["LastName"].ToString();
             textBox_balance.Text   = user.GetData().Rows[i]["Balance"].ToString();
             break;
         }
     }
     InfoArea.Text = "";
     InfoArea.AppendText("Операция" + "\t" +
                         "Номер" + "\t" +
                         "Было денег" + "    " +
                         "Списано" + "    " +
                         "Стало денег" + "    " +
                         "Время парковки" + "        " +
                         "Дата" + "\n" + "\t\t\t\t    " +
                         "/Пополнено" + "\n\n");
     for (int i = 0; i < userInfo.GetData().Rows.Count; i++)
     {
         if (comboBox_num.Text == userInfo.GetData().Rows[i]["CarNumber"].ToString())
         {
             date = userInfo.GetData().Rows[i]["Date"].ToString();
             if (userInfo.GetData().Rows[i]["Operation"].ToString() == "Пополнение")
             {
                 InfoArea.SelectionColor = Color.Green;
             }
             else
             {
                 InfoArea.SelectionColor = Color.Red;
             }
             InfoArea.AppendText(userInfo.GetData().Rows[i]["Operation"].ToString() + "\t");
             InfoArea.AppendText(userInfo.GetData().Rows[i]["CarNumber"].ToString() + "\t" +
                                 "  " +
                                 Double.Parse(userInfo.GetData().Rows[i]["Balance"].ToString()).ToString("0.00") + "\t\t" +
                                 Double.Parse(userInfo.GetData().Rows[i]["Money"].ToString()).ToString("0.00") + "\t" +
                                 Double.Parse(userInfo.GetData().Rows[i]["NewBalance"].ToString()).ToString("0.00") + "\t\t" +
                                 userInfo.GetData().Rows[i]["ParkingTime"].ToString() + " мин." + "\t" +
                                 date + "\n");
             InfoArea.SelectionColor = Color.Black;
             InfoArea.AppendText("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
         }
     }
 }
        /// <summary>
        /// Searches the operation did finish with count.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="count">The count.</param>
        public void SearchOperationDidFinishWithCount(Operation operation, int count)
        {
            this.ControllerState = GroupModelControllerState.Finished;
            UPMInsightBoardItem item = (UPMInsightBoardItem)this.Group.Children[0];

            item.Countable = true;
            item.Count     = count;
            item.SortIndex = this.SortIndex;
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(this.searchAndListConfigurationName);

            this.infoAreaid = searchAndList.InfoAreaId;
            InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.infoAreaid);

            if (!string.IsNullOrEmpty(infoAreaConfig.ColorKey))
            {
                item.Color = AureaColor.ColorWithString(infoAreaConfig.ColorKey);
            }

            if (!string.IsNullOrEmpty(this.Menu.DisplayName))
            {
                item.Title = this.Menu.DisplayName;
            }
            else
            {
                item.Title = item.Count > 1 ? infoAreaConfig.PluralName : infoAreaConfig.SingularName;
            }

            item.ImageName = this.Menu.ImageName ?? infoAreaConfig.ImageName;
            UPMAction action = new UPMAction(null);

            if (count == 1)
            {
                this.crmQuery.Find(this.requestOption, this);
                action.SetTargetAction(this, this.SwitchToDetailOrganizer);
            }
            else
            {
                action.SetTargetAction(this, this.SwitchToListOrganizer);
            }

            item.Action = action;
            if (count != 1)
            {
                this.Delegate.GroupModelControllerFinished(this);
            }
        }
Example #6
0
        private readonly GameData gameData;                  //Игровая статистика.


        public MapBuilder()
        {
            playAreaWidth    = 9;
            infoAreaWidth    = 15;
            playAreaHeight   = 20;
            BuildingArea     = new bool[playAreaHeight + 1, playAreaWidth + 1];
            _listOfTetramino = new List <ITetramino>()
            {
                new Ltetra(), new Jtetra(), new Ztetra(),
                new Stetra(), new Ttetra(), new Itetra(),
                new Otetra()
            };
            newFigure    = new NewFigure();
            infoArea     = new InfoArea(playAreaWidth, playAreaHeight);
            mapMechanics = new MapMechanics();
            gameData     = new GameData();
        }
Example #7
0
        private void RefreshTableCaption()
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            var    crmStore         = UPCRMDataStore.DefaultStore;
            string tableCaptionName = this.ExpandConfig.TableCaptionName;

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

            UPConfigTableCaption tableCaption = configStore.TableCaptionByName(tableCaptionName);
            string recordTableCaption         = tableCaption?.TableCaptionForRecordIdentification(this.RecordIdentification);

            if (string.IsNullOrEmpty(recordTableCaption) && !crmStore.RecordExistsOffline(this.RecordIdentification))
            {
                this.Organizer.TitleText = configStore.BasicTextByIndex(4);
                tableCaption?.RequestTableCaptionForRecordIdentification(this.RecordIdentification, this);
            }
            else
            {
                this.Organizer.TitleText = recordTableCaption;
            }

            string subTitleText = null;

            if (!string.IsNullOrEmpty(this.ExpandConfig.HeaderGroupName))
            {
                UPConfigHeader header = configStore.HeaderByNameFromGroup("Expand", this.ExpandConfig.HeaderGroupName);
                subTitleText = header?.Label;
            }

            if (string.IsNullOrEmpty(subTitleText))
            {
                InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.InfoAreaId);
                subTitleText = infoAreaConfig.SingularName;
                if (string.IsNullOrEmpty(subTitleText))
                {
                    subTitleText = crmStore.TableInfoForInfoArea(this.InfoAreaId).Label;
                }
            }

            this.Organizer.SubtitleText = subTitleText;
            this.InformAboutDidChangeTopLevelElement(this.Organizer, this.Organizer, null, UPChangeHints.ChangeHintsWithHint("TableCaptionChanged"));
        }
        /// <summary>
        /// Defaults the action for search and list.
        /// </summary>
        /// <param name="searchAndList">The search and list.</param>
        /// <returns></returns>
        public Menu DefaultActionForSearchAndList(SearchAndList searchAndList)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            Menu   tmpDetailAction = null;
            string infoAreaId      = searchAndList.InfoAreaId;

            if (!string.IsNullOrEmpty(searchAndList.DefaultAction))
            {
                tmpDetailAction = configStore.MenuByName(searchAndList.DefaultAction);
            }

            if (tmpDetailAction == null)
            {
                InfoArea infoAreaConfig = configStore.InfoAreaConfigById(infoAreaId);
                if (!string.IsNullOrEmpty(infoAreaConfig.DefaultAction))
                {
                    tmpDetailAction = configStore.MenuByName(infoAreaConfig.DefaultAction);
                }
            }

            return(tmpDetailAction ?? configStore.MenuByName("SHOWRECORD"));
        }
        private void UpdatePageFromQueryResult(UPCRMResult result)
        {
            this.QueryResult = result;
            UPMGridPage      searchPage = (UPMGridPage)this.CreatePageInstance();
            Page             oldPage = this.Page;
            int              i, j;
            int              columnCount         = result.ColumnCount;
            StringIdentifier identifier          = StringIdentifier.IdentifierWithStringId("columnHeader");
            UPMResultSection section             = new UPMResultSection(identifier);
            UPMResultRow     columnHeaderListRow = new UPMResultRow(identifier);
            var              fieldArray          = new List <UPMField>();

            searchPage.FixedFirstColumn = false;
            searchPage.ShowMenu         = true;
            searchPage.SumRowAtEnd      = false;
            for (i = 0; i < columnCount; i++)
            {
                UPContainerFieldMetaInfo fieldMetaInfo = result.ColumnFieldMetaInfoAtIndex(i);
                string fieldType = fieldMetaInfo.CrmFieldInfo.FieldType;
                if (fieldType == "F" || fieldType == "L" || fieldType == "S")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Numeric, false);
                }
                else if (fieldType == "D")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Date, true);
                }

                UPMGridColumnHeaderStringField field = new UPMGridColumnHeaderStringField(StringIdentifier.IdentifierWithStringId($"col {i}"))
                {
                    StringValue = result.ColumnNameAtIndex(i)
                };
                fieldArray.Add(field);
            }

            columnHeaderListRow.Fields = fieldArray;
            section.AddResultRow(columnHeaderListRow);
            searchPage.AddResultSection(section);
            int           numberOfResultTables = result.NumberOfResultTables;
            List <object> contextMenuOptions   = new List <object>(numberOfResultTables);
            var           configStore          = ConfigurationUnitStore.DefaultStore;

            for (j = 0; j < numberOfResultTables; j++)
            {
                string infoAreaId    = result.ResultTableAtIndex(j).InfoAreaId;
                string infoAreaLabel = string.Empty;
                if (infoAreaId?.Length > 0)
                {
                    InfoArea       configInfoArea = configStore.InfoAreaConfigById(infoAreaId);
                    UPConfigExpand expand         = configStore.ExpandByName(infoAreaId);
                    FieldControl   fieldControl   = configStore.FieldControlByNameFromGroup("Details", expand.FieldGroupName);
                    if (configInfoArea != null && expand != null && fieldControl != null)
                    {
                        infoAreaLabel = LocalizedString.TextAnalysesShowParam.Replace("%@", configInfoArea.SingularName);
                    }
                }

                contextMenuOptions.Add(infoAreaLabel);
            }

            for (i = 0; i < result.RowCount; i++)
            {
                identifier = StringIdentifier.IdentifierWithStringId($"row {i}");
                var listRow = new UPMResultRow(identifier);
                var crmRow  = result.ResultRowAtIndex(i) as UPCRMResultRow;
                fieldArray = new List <UPMField>();
                var v = crmRow.Values();
                for (j = 0; j < v.Count; j++)
                {
                    UPMStringField field2 = new UPMStringField(StringIdentifier.IdentifierWithStringId($"cell{i}_{j}"))
                    {
                        StringValue    = v[j],
                        RawStringValue = crmRow.RawValueAtIndex(j)
                    };
                    fieldArray.Add(field2);
                }

                listRow.Fields = fieldArray;
                section.AddResultRow(listRow);
                for (j = 0; j < numberOfResultTables; j++)
                {
                    var label = contextMenuOptions[j] as string;
                    if (label.Length == 0)
                    {
                        continue;
                    }

                    string recordIdentification = crmRow.RecordIdentificationAtIndex(j);
                    if (recordIdentification?.Length > 0)
                    {
                        UPMOrganizerAnalysisShowRecordAction showRecordAction = new UPMOrganizerAnalysisShowRecordAction(StringIdentifier.IdentifierWithStringId($"action.row {i} record {j}"))
                        {
                            RecordIdentification = recordIdentification
                        };
                        showRecordAction.SetTargetAction(this, this.PerformShowRecordAction);
                        showRecordAction.LabelText = label;
                        listRow.AddDetailAction(showRecordAction);
                    }
                }
            }

            this.TopLevelElement = searchPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, searchPage, null, null);
        }
Example #10
0
        private void GenerateTunnels(object sender, EventArgs e) //generate tunnels (button pressed)
        {
            if (!int.TryParse(tunnelsize.Text, out int size))
            {
                size = 24;        //get tunnel size from form
            }
            numtunnels = 0;       //set number tunnels to 0
            Tunnel path, endpath; //temporary tunnels storage

            for (int i = 0; i < maxtunnels; i++)
            {
                istunnel[i] = false;           //clear all tunnels
            }
            int first = 0;                     //set first to 0

            for (int i = 0; i < maxrooms; i++) //use first room
            {
                if (isroom[i])                 //if room exists
                {
                    first = i;                 //set first to room number
                    i     = maxrooms;          //exit loop
                }
            }
            keepgoing = true;                              //set keep going flag to true
            while (keepgoing)                              //while we are supposed to keep going
            {
                int next = 0;                              //set next room to 0
                for (int i = first + 1; i < maxrooms; i++) //use first room (after first)
                {
                    if (isroom[i])                         //if room exists
                    {
                        next = i;                          //set next to room number
                        i    = maxrooms;                   //exit loop
                    }
                }
                if (next == 0)
                {
                    keepgoing = false;            //if there was no next room, we are done
                }
                else //otherwise (keep going)
                {
                    int dist = rooms[next].GetDistance(rooms[first]);      //get distance from first room to next room
                    for (int i = first - 1; i > -1; i--)                   //check all rooms before first room (already processed rooms)
                    {
                        if (rooms[next].GetDistance(rooms[i]) < dist)      //if room is at a shorter distance
                        {
                            first = i;                                     //set first to that room number
                            dist  = rooms[next].GetDistance(rooms[first]); //set that room's distance for further testing
                        }
                    }
                    rooms[first].GetDir(rooms[next], out int xdir, out int ydir);                                 //get hint for direction
                    if (Math.Abs(xdir) > Math.Abs(ydir))                                                          //if x distance is greater than y distance
                    {
                        if (xdir > 0)                                                                             //if x direction is positive
                        {
                            path    = new Tunnel(rooms[first].LastX() + 1, rooms[first].MidY() - size / 2, size); //make first tunnel
                            path    = AddTunnel(path, 0, 0);                                                      //add it to tunnels
                            path    = AddTunnel(path, size, 0);                                                   //add next tunnel
                            endpath = new Tunnel(rooms[next].X - size + 1, rooms[next].MidY() - size / 2, size);  //make end tunnel
                        }
                        else //otherwise (x direction is negative)
                        {
                            path    = new Tunnel(rooms[first].X - size + 1, rooms[first].MidY() - size / 2, size); //make first tunnel
                            path    = AddTunnel(path, 0, 0);                                                       //add it to tunnels
                            path    = AddTunnel(path, -size, 0);                                                   //add next tunnel
                            endpath = new Tunnel(rooms[next].LastX() + 1, rooms[next].MidY() - size / 2, size);    //make end tunnel
                        }
                    }
                    else //otherwise (y distance greater than x distance)
                    {
                        if (ydir > 0) //if y direction is positive
                        {
                            path    = new Tunnel(rooms[first].MidX() - size / 2, rooms[first].LastY() + 1, size); //make first tunnel
                            path    = AddTunnel(path, 0, 0);                                                      //add it to tunnels
                            path    = AddTunnel(path, 0, size);                                                   //add next tunnel
                            endpath = new Tunnel(rooms[next].MidX() - size / 2, rooms[next].Y - size + 1, size);  //make end tunnel
                        }
                        else //otherwise (y direction is negative)
                        {
                            path    = new Tunnel(rooms[first].MidX() - size / 2, rooms[first].Y - size + 1, size); //make first tunnel
                            path    = AddTunnel(path, 0, 0);                                                       //add it to tunnels
                            path    = AddTunnel(path, 0, -size);                                                   //add next tunnel
                            endpath = new Tunnel(rooms[next].MidX() - size / 2, rooms[next].LastY() + 1, size);    //make end tunnel
                        }
                    }
                    while (!path.IsHit(rooms[next]))              //while tunnel has not reached next room
                    {
                        path.GetDir(endpath, out xdir, out ydir); //get hint for direction to end tunnel
                        if ((xdir < size) && (-size < xdir) && (ydir < size) && (-size < ydir))
                        {
                            path.GetDir(rooms[next], out xdir, out ydir); //if end tunnel too close, use next room
                        }
                        if (Math.Abs(xdir) > Math.Abs(ydir))              //if x distance greater than y distance
                        {
                            if (xdir > 0)
                            {
                                path = AddTunnel(path, size, 0);           //if x direction positive, add tunnel that way
                            }
                            else
                            {
                                path = AddTunnel(path, -size, 0);  //otherwise (x direction negative), add tunnel that way
                            }
                        }
                        else //otherwise (y distance greater than x distance)
                        {
                            if (ydir > 0)
                            {
                                path = AddTunnel(path, 0, size);           //if y direction position, add tunnel that way
                            }
                            else
                            {
                                path = AddTunnel(path, 0, -size);  //otherwise (y direction negative), add tunnel that way
                            }
                        }
                    }
                    first = next; //set first room to next room (set as processed)
                }
            }
            MapArea.Invalidate();  //redraw map area
            InfoArea.Invalidate(); //redraw information area
        }
        public async Task <IActionResult> AreaInfoCreate([Bind("AreaCode,AreaName,AreaPid,AreaLevel,AreaCoord,AreaZipCode,AreaNote,UpAreaName,UpAreaPathId")] AreaInfo _areaInfo)
        {
            if (ModelState.IsValid)
            {
                #region 验证是否存在重复
                if (_context.InfoArea.Any(b => b.AreaName.ToUpper() == _areaInfo.AreaName.Trim().ToUpper() && b.AreaLevel.Equals(_areaInfo.AreaLevel)))//验证名称是否重复
                {
                    this.MsgBox("已存在相同的名称!");
                    return(View(_areaInfo));
                }
                else if (_context.InfoArea.Any(b => b.AreaCode.ToUpper() == _areaInfo.AreaCode.Trim().ToUpper()))//验证编号是否重复
                {
                    this.MsgBox("已存在相同的编号!");
                    return(View(_areaInfo));
                }
                #endregion
                var a1 = _context.InfoArea.Select(s => s.AreaId.ToString()).Max() ?? "";
                var b2 = _dataClass.GetSerialNumber(a1.ToString());
                var c3 = _dataClass.FormatCode(b2).ToInt();
                _areaInfo.AreaId = c3;
                if (_areaInfo.AreaLevel > 0)
                {
                    _areaInfo.AreaPathId = _areaInfo.UpAreaPathId + "" + _areaInfo.AreaId + "|";
                }
                else if (_areaInfo.AreaLevel == 0)
                {
                    _areaInfo.AreaPathId = "|" + _areaInfo.AreaId + "|";
                }

                InfoArea infoArea = new InfoArea
                {
                    AreaId      = _areaInfo.AreaId,
                    AreaCode    = _areaInfo.AreaCode.Trim(),
                    AreaName    = _areaInfo.AreaName.Trim(),
                    AreaPathId  = _areaInfo.AreaPathId,
                    AreaPid     = _areaInfo.AreaPid,
                    AreaLevel   = _areaInfo.AreaLevel,
                    AreaCoord   = _areaInfo.AreaCoord,
                    AreaZipCode = _areaInfo.AreaZipCode,
                    AreaNote    = _areaInfo.AreaNote
                };
                _context.Add(infoArea);
                var result = await _context.SaveChangesAsync();

                if (result > 0)
                {
                    this.MsgBox("提交成功!");
                    _context.SysLogger.Add(new SysLogger
                    {
                        LoggerCreateTime  = DateTime.Now,
                        LoggerDescription = $"{EmLogStatus.增加}地区{infoArea.AreaName}信息",
                        LoggerIps         = _MyUserInfo.UserIps,
                        LoggerOperation   = (int)EmLogStatus.增加,
                        LoggerUser        = _MyUserInfo.UserId
                    });
                    await _context.SaveChangesAsync();

                    Response.Redirect($"AreaInfoCreate?tag=add&level={_areaInfo.AreaLevel}&id={_areaInfo.AreaId}");
                }
                else
                {
                    this.MsgBox("提交失败!请稍后再试...");
                    return(View(_areaInfo));
                }
            }
            return(View(_areaInfo));
        }
Example #12
0
        /// <summary>
        /// Search operation did finish with result
        /// </summary>
        /// <param name="operation">Operation</param>
        /// <param name="result">Result</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(0);

            this.resCount--;
            if (resultRow != null)
            {
                string           recordIdent      = resultRow.RootRecordIdentification;
                RecordIdentifier recordIdentifier = new RecordIdentifier(recordIdent.InfoAreaId(), recordIdent.RecordId());
                UPMResultRow     row = new UPMResultRow(new RecordIdentifier(recordIdent));
                SearchAndList    searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId());
                FieldControl     listFieldControl    = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName);
                InfoArea         configInfoArea      = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId());
                row.RowColor = AureaColor.ColorWithString(configInfoArea.ColorKey);
                UPCRMListFormatter listFormatter = new UPCRMListFormatter(listFieldControl);
                int             fieldCount       = listFormatter.PositionCount;
                List <UPMField> listFields       = new List <UPMField>(fieldCount);
                for (int i = 0; i < fieldCount; i++)
                {
                    UPConfigFieldControlField configField = listFormatter.FirstFieldForPosition(i);
                    if (configField == null)
                    {
                        continue;
                    }

                    FieldAttributes attributes = configField.Attributes;
                    if (attributes.Hide)
                    {
                        continue;
                    }

                    UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{recordIdent}-{i}"));
                    string         stringValue = listFormatter.StringFromRowForPosition(resultRow, i);
                    if (attributes.Image)
                    {
                        DocumentManager documentManager = new DocumentManager();
                        string          documentKey     = stringValue;
                        DocumentData    documentData    = documentManager.DocumentForKey(documentKey);
                        if (documentData != null)
                        {
                            row.RecordImageDocument = new UPMDocument(documentData);
                        }
                        else
                        {
                            //row.RecordImageDocument = new UPMDocument(recordIdentifier, ServerSession.DocumentRequestUrlForDocumentKey(documentKey));
                        }

                        continue;
                    }

                    if (!string.IsNullOrEmpty(stringValue))
                    {
                        if (attributes.NoLabel && !string.IsNullOrEmpty(configField.Label))
                        {
                            stringValue = $"{configField.Label} {stringValue}";
                        }

                        stringField.StringValue = stringValue;
                        stringField.SetAttributes(attributes);
                    }

                    listFields.Add(stringField);
                }

                row.OnlineData = resultRow.IsServerResponse;
                if (row.OnlineData)
                {
                    //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud");    // CRM-5007
                }

                foreach (HistoryEntry entry in this.historyManager.HistoryEntries)
                {
                    if (entry.RecordIdentification == recordIdent)
                    {
                        this.rows.Add(row);
                        if (this.pendingRecords.Contains(recordIdent))
                        {
                            this.pendingRecords.Remove(recordIdent);
                        }

                        break;
                    }
                }

                row.Fields = listFields;
            }

            if (this.resCount == 0)
            {
                this.DisplayPage(this.rows);
            }
        }
Example #13
0
        private UPMSearchPage UpdatePage(UPMSearchPage searchPage)
        {
            UPMSearchPage newPage = this.CreatePageInstance();

            this.BuildPageDetails(newPage);
            if (searchPage.Invalid)
            {
                this.pendingRecords.Clear();
                this.rows.Clear();
                this.historyManager = HistoryManager.DefaultHistoryManager;
                this.configStore    = ConfigurationUnitStore.DefaultStore;
                if (this.historyManager.HistoryEntries.Count == 0)
                {
                    return(newPage);
                }

                foreach (HistoryEntry entry in this.historyManager.HistoryEntries)
                {
                    string              recordIdent         = entry.RecordIdentification;
                    SearchAndList       searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId());
                    FieldControl        listFieldControl    = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName);
                    UPContainerMetaInfo containerMetaInfo   = new UPContainerMetaInfo(listFieldControl);
                    if (entry.OnlineData)
                    {
                        if (ServerSession.CurrentSession.ConnectedToServer)
                        {
                            this.pendingRecords.Add(recordIdent);
                            this.resCount++;
                            containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Online, this);
                        }
                        else
                        {
                            UPMResultRow   row         = new UPMResultRow(new RecordIdentifier(recordIdent));
                            UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId(recordIdent));
                            stringField.FieldValue = LocalizedString.TextOfflineNotAvailable;
                            row.Fields             = new List <UPMField> {
                                stringField
                            };
                            row.OnlineData = true;
                            //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud");    // CRM-5007
                            InfoArea infoAreaConfig = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId());
                            string   imageName      = infoAreaConfig.ImageName;
                            if (!string.IsNullOrEmpty(imageName))
                            {
                                //row.Icon = UIImage.UpImageWithFileName(imageName);    // CRM-5007
                            }

                            this.rows.Add(row);
                        }
                    }
                    else
                    {
                        this.resCount++;
                        this.pendingRecords.Add(recordIdent);
                        containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Offline, this);
                    }
                }

                newPage.Invalid      = false;
                this.TopLevelElement = newPage;
                this.ApplyLoadingStatusOnPage(newPage);
                return(newPage);
            }

            UPMResultSection section = (UPMResultSection)this.Page.Children[0];

            this.ResortRowListAddToPage(section.Children, newPage);
            this.TopLevelElement = newPage;
            return(newPage);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSearchPageModelControllerPreparedSearch"/> class.
        /// </summary>
        /// <param name="timelineInfoAreaConfiguration">
        /// The timeline info area configuration.
        /// </param>
        public UPSearchPageModelControllerPreparedSearch(ConfigTimelineInfoArea timelineInfoAreaConfiguration)
        {
            this.InfoAreaId            = timelineInfoAreaConfiguration.InfoAreaId;
            this.ConfigName            = timelineInfoAreaConfiguration.ConfigName;
            this.TimelineConfiguration = timelineInfoAreaConfiguration;

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

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

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

            string fieldGroupName;

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

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

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

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

            this.FilterName = timelineInfoAreaConfiguration.FilterName;

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

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

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

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

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

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

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

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

                    string key = field.FieldId.ToString();

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

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

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

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

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

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

            this.FilterName = filterName;

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

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

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

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

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

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

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

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

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

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

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

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

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

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

            this.ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet(@"Search.ReplaceCaseSensitiveCharacters");
        }