Пример #1
0
        private void Gen(StringBuilder sb, string tmp, IViewInfo vwInfo)
        {
            string code = codeGen.Gen(tmp, vwInfo);

            bool sqlLine = false;
            bool sqlBegin = false;
            using (StringReader sr = new StringReader(code))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf(" sql = ") > -1 && sqlBegin == false)
                    {
                        sqlBegin = true;
                        sqlLine = true;
                        sb.Append("        ");
                    }

                    if (!string.IsNullOrEmpty(line) && !sqlLine)
                    {
                        sb.Append("        ");
                    }
                    sb.Append(line);
                    sb.Append(Environment.NewLine);

                    if (sqlBegin && line.EndsWith("\";"))
                    {
                        sqlBegin = false;
                        sqlLine = false;
                    }
                }//while
            }//using

            sb.AppendLine();
        }
Пример #2
0
        public override void LoadDetail()
        {
            lblTableName.Text = "";
            //lblTableDBDesc.Text = "";//db_desc
            //lblTableLocalDesc.Text = "";//local_desc
            txtTableNewDesc.Text = "";//new_desc
            dgvSchema.Rows.Clear();

            this.node = App.Instance.SelectedNode;
            this.view = App.Instance.SelectedNode.Tag as IViewInfo;

            if (this.view != null)
            {
                lblTableName.Text = this.view.RawName;
                //lblTableDBDesc.Text = this.view.Description;//db_desc
                //lblTableLocalDesc.Text = this.view.Attributes.ContainsKey("local_desc") ? this.view.Attributes["local_desc"] : "";//local_desc
                //txtTableNewDesc.Text = this.view.Attributes.ContainsKey("new_desc") ? this.view.Attributes["new_desc"] : "";//new_desc
                txtTableNewDesc.Text = this.view["local_desc"] ?? "";//local_desc

                //foreach (var item in this.view.Columns)
                //{
                //    int index = dgvSchema.Rows.Add();
                //    DataGridViewRow row = dgvSchema.Rows[index];
                //    //row.Tag = item.IsPrimaryKey;
                //    row.Cells[0].Value = item.RawName;
                //    row.Cells[1].Value = SQLHelper.GetFullSqlType(item);
                //    row.Cells[2].Value = item.Nullable ? true : false;
                //    //row.Cells[3].Value = item.Description;
                //    //row.Cells[4].Value = item.Attributes.ContainsKey("local_desc") ? item.Attributes["local_desc"] : "";
                //    //row.Cells[5].Value = item.Attributes.ContainsKey("new_desc") ? item.Attributes["new_desc"] : "";
                //    row.Cells[3].Value = item["local_desc"] ?? "";
                //}

                List<DataGridViewRow> rlist = new List<DataGridViewRow>();
                foreach (var item in this.view.Columns)
                {
                    DataGridViewTextBoxCell col1 = new DataGridViewTextBoxCell();
                    col1.Value = item.RawName;

                    DataGridViewTextBoxCell col2 = new DataGridViewTextBoxCell();
                    col2.Value = SQLHelper.GetFullSqlType(item);

                    DataGridViewCheckBoxCell col3 = new DataGridViewCheckBoxCell();
                    col3.Value = item.Nullable ? true : false;

                    DataGridViewTextBoxCell col4 = new DataGridViewTextBoxCell();
                    col4.Value = item["local_desc"] ?? "";

                    DataGridViewTextBoxCell col5 = new DataGridViewTextBoxCell();

                    DataGridViewRow row = new DataGridViewRow();
                    row.Cells.AddRange(new DataGridViewCell[] { col1, col2, col3, col4, col5 });
                    rlist.Add(row);
                }

                dgvSchema.Rows.AddRange(rlist.ToArray());
            }
        }
        /// <summary>
        /// Creates a view from a view object
        /// </summary>
        /// <param name="workspace">Workspace context</param>
        /// <param name="view">View information</param>
        public void Show( IWorkspace workspace, IViewInfo view )
        {
            if ( view is HostedViewInfo )
            {
                //	Make sure the host window is visible
                DockContent dockContent = m_UnhostedViewManager.Show( workspace, m_HostViewInfo );
                Panel hostPanel = ( Panel )dockContent.Controls[ 0 ];
                hostPanel.Controls.Clear( );

                Control hostedControl = ( ( HostedViewInfo )view ).CreateControl( workspace );
                hostedControl.Dock = DockStyle.Fill;
                hostPanel.Controls.Add( hostedControl );

                return;
            }
            if ( view is DockingViewInfo )
            {
                m_UnhostedViewManager.Show( workspace, view );
                return;
            }
            throw new NotSupportedException( "Unsupported view type " + view.GetType( ) );
        }
Пример #4
0
        //private readonly string Temp_View_Model = Comm.GetTemplete("View.Model.cshtml");
        //private readonly string Temp_View_Exist = Comm.GetTemplete("View.Exist.cshtml");
        //private readonly string Temp_View_Get = Comm.GetTemplete("View.Get.cshtml");
        //private readonly string Temp_View_GetAll = Comm.GetTemplete("View.GetAll.cshtml");
        //private readonly string Temp_View_Top = Comm.GetTemplete("View.Top.cshtml");
        //private readonly string Temp_View_Paged = Comm.GetTemplete("View.Paged.cshtml");
        //private readonly string Temp_View_GetBytes = Comm.GetTemplete("_GetBytes.cshtml");
        //private readonly string Temp_View_GetMany = Comm.GetTemplete("View._GetMany.cshtml");

        public string GenDataAccessCode(string nameSpace, IViewInfo vwInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("using System;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using System.Data;");
            sb.AppendLine("using System.Data.SqlClient;");
            sb.AppendLine("using System.Linq;");
            sb.AppendLine("using System.Text;");
            sb.AppendFormat("using {0};{1}", nameSpace, Environment.NewLine);
            sb.AppendFormat("using {0}.Model;{1}", nameSpace, Environment.NewLine);
            sb.AppendLine();
            sb.AppendFormat("namespace {0}.DAL{1}", nameSpace, Environment.NewLine);
            sb.AppendLine("{");
            sb.AppendFormat("    public class {0}Access{1}", vwInfo.PascalName, Environment.NewLine);
            sb.AppendLine("    {");

            //Gen(sb, Comm.GetTemplete("View.Exist.cshtml"), vwInfo);
            //Gen(sb, Comm.GetTemplete("View.Get.cshtml"), vwInfo);
            //Gen(sb, Comm.GetTemplete("View.Top.cshtml"), vwInfo);
            Gen(sb, Comm.GetTemplete("View.GetAll.cshtml"), vwInfo);
            Gen(sb, Comm.GetTemplete("View.Paged.cshtml"), vwInfo);

            if ((from col in vwInfo.Columns
                 where col.DbTargetType == "SqlDbType.Image" || col.DbTargetType == "SqlDbType.Binary"
                 || col.DbTargetType == "SqlDbType.VarBinary" || col.DbTargetType == "SqlDbType.Timestamp"
                 select col).Count() > 0)
            {
                Gen(sb, Comm.GetTemplete("_GetBytes.cshtml"), vwInfo);
            }

            Gen(sb, Comm.GetTemplete("View._GetMany.cshtml"), vwInfo);

            sb.AppendLine("    }");
            sb.AppendLine("}");

            return sb.ToString();
        }
Пример #5
0
        public override BUSJoinSpecification UIToBusiness(UIJoinSpecification UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSJoinSpecification businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            Join join = context.Joins
                        .AsNoTracking()
                        .Select(j => new
            {
                id   = j.Id,
                name = j.Name,
                joinSpecifications = j.JoinSpecifications.Select(joinSpecification => new
                {
                    id   = joinSpecification.Id,
                    name = joinSpecification.Name
                }),
                table = new
                {
                    id           = j.Table.Id,
                    tableColumns = j.Table.TableColumns.Select(joinColumn => new
                    {
                        id   = joinColumn.Id,
                        name = joinColumn.Name
                    })
                },
                tableId = j.TableId,
                busComp = new
                {
                    id    = j.BusCompId,
                    table = new
                    {
                        id           = j.BusComp.Table.Id,
                        tableColumns = j.BusComp.Table.TableColumns.Select(joinColumn => new
                        {
                            id   = joinColumn.Id,
                            name = joinColumn.Name
                        })
                    },
                    fields = j.BusComp.Fields.Select(field => new
                    {
                        id   = field.Id,
                        name = field.Name
                    })
                },
                busCompId = j.BusCompId,
            })
                        .Select(j => new Join
            {
                Id   = j.id,
                Name = j.name,
                JoinSpecifications = j.joinSpecifications.Select(joinSpecification => new JoinSpecification
                {
                    Id   = joinSpecification.id,
                    Name = joinSpecification.name
                }).ToList(),
                Table = new Table
                {
                    Id           = j.table.id,
                    TableColumns = j.table.tableColumns.Select(joinColumn => new TableColumn
                    {
                        Id   = joinColumn.id,
                        Name = joinColumn.name
                    }).ToList()
                },
                TableId = j.tableId,
                BusComp = new BusinessComponent
                {
                    Id    = j.busCompId,
                    Table = new Table
                    {
                        Id           = j.busComp.table.id,
                        TableColumns = j.busComp.table.tableColumns.Select(tableColumn => new TableColumn
                        {
                            Id   = tableColumn.id,
                            Name = tableColumn.name
                        }).ToList()
                    },
                    Fields = j.busComp.fields.Select(field => new Field
                    {
                        Id   = field.id,
                        Name = field.name
                    }).ToList()
                },
                BusCompId = j.busCompId,
            })
                        .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Join"));

            if (join == null)
            {
                businessEntity.ErrorMessage = "First you need create join.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                JoinSpecification joinSpecification = join.JoinSpecifications?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (joinSpecification != null && joinSpecification.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Join specification with this name is already exists in join {join.Name}.";
                }
                else
                {
                    // BusComp
                    BusinessComponent busComp = join.BusComp;

                    // Join
                    businessEntity.Join      = join;
                    businessEntity.JoinId    = join.Id;
                    businessEntity.BusComp   = join.BusComp;
                    businessEntity.BusCompId = join.BusCompId;
                    businessEntity.Table     = join.Table;
                    businessEntity.TableId   = join.TableId;

                    // Source field
                    Field field = busComp.Fields.FirstOrDefault(n => n.Name == UIEntity.SourceFieldName);
                    if (field != null)
                    {
                        businessEntity.SourceField     = field;
                        businessEntity.SourceFieldId   = field.Id;
                        businessEntity.SourceFieldName = field.Name;
                    }

                    // Destination column
                    TableColumn destinationColumn = join.Table.TableColumns.FirstOrDefault(n => n.Name == UIEntity.DestinationColumnName);
                    if (destinationColumn != null)
                    {
                        businessEntity.DestinationColumn     = destinationColumn;
                        businessEntity.DestinationColumnId   = destinationColumn.Id;
                        businessEntity.DestinationColumnName = destinationColumn.Name;
                    }
                }
            }
            return(businessEntity);
        }
 public DirectoriesListController(ToolsContext context, IScreenInfo screenInfo, IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
Пример #7
0
 public PickMapController(TContext context, IViewInfo viewInfo)
     : base(context, viewInfo)
 {
 }
Пример #8
0
 public string GenPagedCode(IViewInfo vwInfo)
 {
     return codeGen.Gen(Comm.GetTemplete("View.Paged.cshtml"), vwInfo);
 }
 public TableController(GSAppContext context,
                        IScreenInfo screenInfo,
                        IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
Пример #10
0
        public void StartInitialize <TContext>(IViewInfo oldViewInfo, string viewName, TContext context)
            where TContext : MainContext, new()
        {
            // Инициализация списков
            ViewBCs              = new List <BusinessComponent>();
            ViewApplets          = new List <Applet>();
            AppletsSortedByLinks = oldViewInfo == null ? new List <Applet>() : oldViewInfo.AppletsSortedByLinks;
            ViewItems            = new List <ViewItem>();
            BOComponents         = new List <BusinessObjectComponent>();

            if (ActionType != ActionType.Drilldown)
            {
                ActionType = ActionType.InitializeView;
            }

            // Получение представления
            View = context.Views
                   .AsNoTracking()
                   .Select(v => new
            {
                id          = v.Id,
                name        = v.Name,
                busObjectId = v.BusObjectId,
                viewItems   = v.ViewItems.Select(vi => new
                {
                    id       = vi.Id,
                    name     = vi.Name,
                    sequence = vi.Sequence,
                    appletId = vi.AppletId,
                    applet   = vi.Applet == null ? null : new
                    {
                        id        = vi.Applet.Id,
                        name      = vi.Applet.Name,
                        busCompId = vi.Applet.BusCompId
                    }
                })
            })
                   .Select(v => new View
            {
                Id          = v.id,
                Name        = v.name,
                BusObjectId = v.busObjectId,
                ViewItems   = v.viewItems.Select(vi => new ViewItem
                {
                    Id       = vi.id,
                    Name     = vi.name,
                    Sequence = vi.sequence,
                    AppletId = vi.appletId,
                    Applet   = vi.applet == null ? null : new Applet
                    {
                        Id        = vi.applet.id,
                        Name      = vi.applet.name,
                        BusCompId = vi.applet.busCompId
                    }
                }).ToList()
            })
                   .FirstOrDefault(n => n.Name == viewName);

            // Получение списка элементов представления
            ViewItems = View.ViewItems.OrderBy(s => s.Sequence).ToList();

            // Получение бизнес объекта, на котором основано представление
            ViewBO = context.BusinessObjects
                     .AsNoTracking()
                     .Select(bo => new
            {
                id           = bo.Id,
                name         = bo.Name,
                boComponents = bo.BusObjectComponents.Select(boc => new
                {
                    id        = boc.Id,
                    name      = boc.Name,
                    busCompId = boc.BusCompId,
                    busComp   = boc.BusComp == null ? null : new
                    {
                        id   = boc.BusComp.Id,
                        name = boc.BusComp.Name
                    },
                    linkId = boc.LinkId,
                    link   = boc.Link == null ? null : new
                    {
                        id            = boc.Link.Id,
                        name          = boc.Link.Name,
                        parentBCId    = boc.Link.ParentBCId,
                        parentFieldId = boc.Link.ParentFieldId,
                        childBCId     = boc.Link.ChildBCId,
                        childFieldId  = boc.Link.ChildFieldId
                    }
                })
            })
                     .Select(bo => new BusinessObject
            {
                Id   = bo.id,
                Name = bo.name,
                BusObjectComponents = bo.boComponents.Select(boc => new BusinessObjectComponent
                {
                    Id        = boc.id,
                    Name      = boc.name,
                    BusCompId = boc.busCompId,
                    BusComp   = boc.busComp == null ? null : new BusinessComponent
                    {
                        Id   = boc.busComp.id,
                        Name = boc.busComp.name
                    },
                    LinkId = boc.linkId,
                    Link   = boc.link == null ? null : new Link
                    {
                        Id            = boc.link.id,
                        Name          = boc.link.name,
                        ParentBCId    = boc.link.parentBCId,
                        ParentFieldId = boc.link.parentFieldId,
                        ChildBCId     = boc.link.childBCId,
                        ChildFieldId  = boc.link.childFieldId
                    }
                }).ToList()
            })
                     .FirstOrDefault(i => i.Id == View.BusObjectId);

            // Заполнение списков с апплетами, бизнес компонентами и маршрутизацией
            ViewItems.ForEach(viewItem =>
            {
                // Получение апплета для каждого элемента представления
                Applet applet = context.Applets
                                .AsNoTracking()
                                .Include(b => b.BusComp)
                                .Include(col => col.Columns)
                                .ThenInclude(f => f.Field)
                                .Include(cntr => cntr.Controls)
                                .ThenInclude(cnUp => cnUp.ControlUPs)
                                .Include(cntr => cntr.Controls)
                                .ThenInclude(f => f.Field)
                                .FirstOrDefault(i => i.Id == viewItem.AppletId);

                // Добавление апплета и его бизнес компоненты в список
                if (ViewApplets.IndexOf(applet) == -1)
                {
                    ViewApplets.Add(applet);
                }

                if (applet.BusComp != null)
                {
                    BusinessObjectComponent component = ViewBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == applet.BusCompId);
                    if (ViewBCs.IndexOf(applet.BusComp) == -1)
                    {
                        ViewBCs.Add(applet.BusComp);
                    }
                    if (BOComponents.IndexOf(component) == -1)
                    {
                        BOComponents.Add(component);
                    }
                }
            });

            CurrentApplet = ViewApplets.FirstOrDefault();
            CurrentRecord = GetSelectedRecord(ViewBCs.FirstOrDefault(i => i.Id == CurrentApplet?.BusCompId)?.Name);

            /*BOComponents.ForEach(objectComponent =>
             * {
             *  objectComponent.SearchSpecArgs = GetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecArgs);
             *  objectComponent.SearchSpecification = GetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecification);
             *  objectComponent.SearchSpecificationByParent = GetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecificationByParent);
             * });*/
        }
Пример #11
0
 public virtual void CreateController(CodeWriter cw, IViewInfo view)
 {
     cw.WriteLine($"// {view.Name}");
 }
Пример #12
0
 public void Manufacture(IViewInfo viewInfo, Dossier dossier)
 {
 }
 public BusinessObjectController(TContext context, IViewInfo viewInfo)
     : base(context, viewInfo)
 {
 }
Пример #14
0
 public string GenModelCode(IViewInfo vwInfo)
 {
     return codeGen.Gen(Comm.GetTemplete("View.Model.cshtml"), vwInfo);
 }
Пример #15
0
        public static string BuildSQL_Paged(IViewInfo view)
        {
            StringBuilder sb = new StringBuilder();
            int len = view.Columns.Count;
            for (int i = 0; i < len; i++)
            {
                IColumnInfo col = view.Columns[i];
                //if (col.InPrimaryKey)
                //    continue;

                sb.AppendFormat("[{0}]", col.RawName);
                if (i != len - 1)
                {
                    sb.Append("\r\n");
                    sb.Append(' ', 8);
                    sb.Append(",");
                }
            }

            string whereStr = "";
            string sql = string.Format(@"
SELECT * FROM (
    SELECT {3}
        ,(ROW_NUMBER() OVER ({0})) AS RowNumber
    FROM [{1}] {2}
) as t
WHERE PageNumber BETWEEN @Begin AND @End

SELECT @TotalCount = COUNT(*) FROM [{1}] {2}
", GetOrderBy(view), view.RawName, whereStr, sb.ToString());

            return sql;
        }
Пример #16
0
 public InvoiceController(GSAppContext context, IViewInfo viewInfo)
     : base(context, viewInfo)
 {
 }
Пример #17
0
 public virtual void CreateHtmlView(CodeWriter cw, IViewInfo view)
 {
     cw.WriteLine($"<!-- {view.Name} -->");
 }
Пример #18
0
        public override BUSColumn UIToBusiness(UIColumn UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSColumn businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            Applet    applet         = context.Applets
                                       .AsNoTracking()
                                       .Select(a => new
            {
                id        = a.Id,
                name      = a.Name,
                busCompId = a.BusCompId,
                columns   = a.Columns.Select(column => new
                {
                    id   = column.Id,
                    name = column.Name
                })
            })
                                       .Select(a => new Applet
            {
                Id        = a.id,
                Name      = a.name,
                BusCompId = a.busCompId,
                Columns   = a.columns.Select(column => new Column
                {
                    Id   = column.id,
                    Name = column.name
                }).ToList()
            })
                                       .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet"));

            if (applet == null)
            {
                businessEntity.ErrorMessage = "First you need create applet.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                Column column = applet.Columns?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (column != null && column.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Column with this name is already exists in applet {applet.Name}.";
                }

                else
                {
                    // Applet
                    businessEntity.Applet   = applet;
                    businessEntity.AppletId = applet.Id;

                    // BusComp
                    BusinessComponent busComp = context.BusinessComponents
                                                .AsNoTracking()
                                                .Select(bc => new
                    {
                        id     = bc.Id,
                        name   = bc.Name,
                        fields = bc.Fields.Select(field => new
                        {
                            id   = field.Id,
                            name = field.Name
                        })
                    })
                                                .Select(bc => new BusinessComponent
                    {
                        Id     = bc.id,
                        Name   = bc.name,
                        Fields = bc.fields.Select(field => new Field
                        {
                            Id   = field.id,
                            Name = field.name
                        }).ToList()
                    })
                                                .FirstOrDefault(i => i.Id == applet.BusCompId);

                    // BusComp
                    if (busComp != null)
                    {
                        businessEntity.BusComp   = busComp;
                        businessEntity.BusCompId = busComp.Id;

                        // Field
                        Field field = busComp.Fields.FirstOrDefault(n => n.Name == UIEntity.FieldName);
                        if (field != null)
                        {
                            businessEntity.Field     = field;
                            businessEntity.FieldId   = field.Id;
                            businessEntity.FieldName = field.Name;
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(UIEntity.ActionType))
                {
                    businessEntity.ActionType = ActionType.None;
                }
                else
                {
                    businessEntity.ActionType = (ActionType)Enum.Parse(typeof(ActionType), UIEntity.ActionType);
                }
                businessEntity.Readonly = UIEntity.Readonly;
                businessEntity.Header   = UIEntity.Header;
                businessEntity.Type     = UIEntity.Type;
                businessEntity.Required = UIEntity.Required;
            }
            return(businessEntity);
        }
Пример #19
0
        public override BUSPickMap UIToBusiness(UIPickMap UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSPickMap businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            Field      field          = context.Fields.FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Field"));

            if (field == null)
            {
                businessEntity.ErrorMessage = "First you need create field.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                PickMap pickMap = field.PickMaps?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (pickMap != null && pickMap.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Field pick map with this name is already exists in field {UIEntity.Name}.";
                }
                else
                {
                    businessEntity.Field   = field;
                    businessEntity.FieldId = field.Id;

                    // BusComp and pickList
                    PickList pickList = context.PickLists
                                        .AsNoTracking()
                                        .Select(pl => new
                    {
                        id      = pl.Id,
                        busComp = new
                        {
                            id     = pl.BusCompId,
                            fields = pl.BusComp.Fields.Select(field => new
                            {
                                id   = field.Id,
                                name = field.Name,
                            })
                        }
                    })
                                        .Select(pl => new PickList
                    {
                        Id      = pl.id,
                        BusComp = new BusinessComponent
                        {
                            Id     = pl.busComp.id,
                            Fields = pl.busComp.fields.Select(field => new Field
                            {
                                Id   = field.id,
                                Name = field.name
                            }).ToList()
                        }
                    })
                                        .FirstOrDefault(i => i.Id == field.PickListId);

                    // PickList
                    if (pickList != null)
                    {
                        businessEntity.PickList   = pickList;
                        businessEntity.PickListId = pickList.Id;

                        BusinessComponent busComp = context.BusinessComponents
                                                    .AsNoTracking()
                                                    .Select(bc => new
                        {
                            id     = bc.Id,
                            fields = bc.Fields.Select(field => new
                            {
                                id   = field.Id,
                                name = field.Name,
                            })
                        })
                                                    .Select(bc => new BusinessComponent
                        {
                            Id     = bc.id,
                            Fields = bc.fields.Select(field => new Field
                            {
                                Id   = field.id,
                                Name = field.name
                            }).ToList()
                        })
                                                    .FirstOrDefault(i => i.Id == field.BusCompId);

                        BusinessComponent pickListBusComp = pickList.BusComp;
                        businessEntity.BusComp   = busComp;
                        businessEntity.BusCompId = busComp.Id;

                        if (pickListBusComp != null)
                        {
                            businessEntity.PickListBusComp   = pickListBusComp;
                            businessEntity.PickListBusCompId = pickListBusComp.Id;

                            // BusCompField
                            Field busCompField = busComp.Fields.FirstOrDefault(n => n.Name == UIEntity.BusCompFieldName);
                            if (busCompField != null)
                            {
                                businessEntity.BusCompField     = busCompField;
                                businessEntity.BusCompFieldId   = busCompField.Id;
                                businessEntity.BusCompFieldName = busCompField.Name;
                            }

                            // PickListField
                            Field pickListField = pickListBusComp.Fields.FirstOrDefault(n => n.Name == UIEntity.PickListFieldName);
                            if (pickListField != null)
                            {
                                businessEntity.PickListField     = pickListField;
                                businessEntity.PickListFieldId   = pickListField.Id;
                                businessEntity.PickListFieldName = pickListField.Name;
                            }
                        }
                    }

                    businessEntity.Constrain = UIEntity.Constrain;
                }
            }
            return(businessEntity);
        }
Пример #20
0
 public override dynamic GetRecord(Type type, ToolsContext context, IViewInfo viewInfo, BusinessComponent busComp, string propertyName, string propertValue)
 => base.GetRecord(Type.GetType("GSCrmTools.Controllers.ApiControllers.BusinessComponentControllers." + busComp.Routing.Split("/api/")[1].Split('/')[0] + "Controller"),
                   context, viewInfo, busComp, propertyName, propertValue);
 public ColumnController(TContext context, IViewInfo viewInfo)
     : base(context, viewInfo)
 {
 }
 /// <summary>
 /// Starts a layout
 /// </summary>
 /// <param name="workspace">Current workspace</param>
 /// <param name="name">Layout name</param>
 /// <param name="views">All views that can be shown in this layout</param>
 public void BeginLayout( IWorkspace workspace, string name, IViewInfo[] views )
 {
     List<IViewInfo> dockingViews = new List<IViewInfo>( Array.FindAll( views, delegate( IViewInfo view ) { return view is DockingViewInfo; } ) );
     dockingViews.Add( m_HostViewInfo );
     m_UnhostedViewManager.BeginLayout( workspace, name, dockingViews.ToArray( ) );
 }
Пример #23
0
 public DataMapFieldController(GSAppContext context, IScreenInfo screenInfo, IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
 public PickMapController(ToolsContext context,
                          IScreenInfo screenInfo,
                          IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
Пример #25
0
 public Account_Tile_AppletController(GSAppContext context, IScreenInfo screenInfo, IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
 public Create_Account_Address_Popup_AppletController(GSAppContext context, IScreenInfo screenInfo, IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
Пример #27
0
 public IconController(ToolsContext context, IViewInfo viewInfo)
     : base(context, viewInfo)
 {
 }
Пример #28
0
 public DrilldownController(ToolsContext context, IScreenInfo screenInfo, IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
 /// <summary>
 /// Creates a view from a view object
 /// </summary>
 /// <param name="workspace">Workspace context</param>
 /// <param name="view">View information</param>
 public void Show( IWorkspace workspace, IViewInfo view )
 {
     Arguments.CheckNotNull( workspace, "workspace" );
     DockingViewInfo dockView = Arguments.CheckedNonNullCast<DockingViewInfo>( view, "view" );
     Show( workspace, dockView );
 }
Пример #30
0
        public static string BuildGetByWhere(IViewInfo view)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.Append("\r\nSELECT ");// [");

            int len = view.Columns.Count;
            for (int i = 0; i < len; i++)
            {
                IColumnInfo col = view.Columns[i];
                //if (col.InPrimaryKey)
                //    continue;

                sbSql.AppendFormat("[{0}]", col.RawName);
                if (i != len - 1)
                {
                    sbSql.Append("\r\n");
                    sbSql.Append(' ', 6);
                    sbSql.Append(",");
                }
            }
            sbSql.Append("\r\n");
            sbSql.Append(' ', 2);
            sbSql.Append("FROM [");
            sbSql.Append(view.Schema);
            sbSql.Append("].[");
            sbSql.Append(view.RawName);
            sbSql.Append("]\r\n");
            sbSql.Append(GetOrderBy(view));

            return sbSql.ToString();
        }
 /// <summary>
 /// Registers all views available in the current layout
 /// </summary>
 private void RegisterViews( IViewInfo[] views )
 {
     if ( views == null )
     {
         return;
     }
     foreach ( IViewInfo view in views )
     {
         if ( view is DockingViewInfo )
         {
             m_Views.Add( ( DockingViewInfo )view );
         }
     }
 }
Пример #32
0
        public static string GetOrderBy(IViewInfo view)
        {
            IColumnInfo col = null;
            //col = (from p in view.Columns
            //           where p.IsPrimaryKey && p.Identity
            //           select p).FirstOrDefault();

            if (col == null)
            {
                col = (from p in view.Columns
                       where p.LanguageType == "Int32" && p.LowerName.Contains("id")
                       select p).FirstOrDefault();
            }

            if (col == null)
            {
                col = (from p in view.Columns
                       where p.LanguageType == "DateTime" && (p.LowerName.Contains("update") || p.LowerName.Contains("modif"))
                       select p).FirstOrDefault();
            }

            if (col == null)
            {
                col = (from p in view.Columns
                       where p.LanguageType == "DateTime" && (p.LowerName.Contains("create") || p.LowerName.Contains("add"))
                       select p).FirstOrDefault();
            }

            if (col == null)
            {
                col = view.Columns[0];
            }

            return "ORDER BY [" + col.RawName + "] DESC";
        }
 /// <summary>
 /// Saves then closes the current layout before loading a new one
 /// </summary>
 private void SwitchLayout( IWorkspace workspace, string layoutName, IViewInfo[] views )
 {
     Arguments.CheckNotNull( workspace, "workspace" );
     Arguments.CheckNotNullOrEmpty( layoutName, "layoutName" );
     SaveLayout( );
     CloseAllViews( );
     m_LayoutName = layoutName;
     RegisterViews( views );
     LoadLayout( workspace );
     SetupViewShowCommands( workspace, views );
 }
Пример #34
0
        public override BUSControlUP UIToBusiness(UIControlUP UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSControlUP businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            Control      control        = context.Controls
                                          .AsNoTracking()
                                          .Select(a => new
            {
                id         = a.Id,
                name       = a.Name,
                controlUPs = a.ControlUPs.Select(controlUP => new
                {
                    id   = controlUP.Id,
                    name = controlUP.Name
                })
            })
                                          .Select(a => new Control
            {
                Id         = a.id,
                Name       = a.name,
                ControlUPs = a.controlUPs.Select(controlUP => new ControlUP
                {
                    Id   = controlUP.id,
                    Name = controlUP.name
                }).ToList()
            })
                                          .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Control"));

            if (control == null)
            {
                businessEntity.ErrorMessage = "First you need create control.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                ControlUP controlUP = control.ControlUPs?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (controlUP != null && controlUP.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Control user property with this name is already exists in control {control.Name}.";
                }
                else
                {
                    businessEntity.Control   = control;
                    businessEntity.ControlId = control.Id;
                }
            }
            return(businessEntity);
        }
 /// <summary>
 /// Starts a layout
 /// </summary>
 /// <param name="workspace">Current workspace</param>
 /// <param name="name">Layout name</param>
 /// <param name="views">All views that can be displayed in this layout</param>
 public void BeginLayout( IWorkspace workspace, string name, IViewInfo[] views )
 {
     SwitchLayout( workspace, name, views );
 }
        public override IEnumerable <ValidationResult> DataBUSValidate(SysInvoice_1 dataEntity, SysInvoice_2 businessEntity, IViewInfo viewInfo, GSAppContext context)
        {
            List <ValidationResult> result = base.DataBUSValidate(dataEntity, businessEntity, viewInfo, context).ToList();
            Applet currentApplet           = viewInfo.CurrentPopupApplet ?? viewInfo.CurrentApplet;

            return(result);
        }
Пример #37
0
            public void Initialize()
            {
                this.storeFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

                var viewInfoMock = new Mock <IViewInfo>();

                viewInfoMock.Setup(x => x.Id).Returns(Guid.NewGuid());
                viewInfoMock.Setup(e => e.Elements)
                .Returns(new List <IAbstractElementInfo>
                {
                    Mocks.Of <IElementInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true),
                    Mocks.Of <ICollectionInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true),
                    Mocks.Of <IElementInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.ZeroToMany)
                });
                viewInfoMock.Setup(x => x.ExtensionPoints)
                .Returns(new List <IExtensionPointInfo>
                {
                    Mocks.Of <IExtensionPointInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true && e.RequiredExtensionPointId == "ext_1"),
                    Mocks.Of <IExtensionPointInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.ZeroToMany && e.RequiredExtensionPointId == "ext_2"),
                });

                this.viewInfo = viewInfoMock.Object;

                var providedExtension1 = Mocks.Of <IProvidedExtensionPointInfo>().First(x => x.ExtensionPointId == "ext_1");
                var extensionPoint1    = Mocks.Of <IInstalledToolkitInfo>().First(x =>
                                                                                  x.Id == "ext_toolkit_1" &&
                                                                                  x.Schema.Pattern.Id == Guid.NewGuid() &&
                                                                                  x.Schema.Pattern.ExtensionId == "ext_toolkit_1" &&
                                                                                  x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension1 });

                var providedExtension2 = Mocks.Of <IProvidedExtensionPointInfo>().First(x => x.ExtensionPointId == "ext_2");
                var extensionPoint2    = Mocks.Of <IInstalledToolkitInfo>().First(x =>
                                                                                  x.Id == "ext_toolkit_2" &&
                                                                                  x.Schema.Pattern.Id == Guid.NewGuid() &&
                                                                                  x.Schema.Pattern.ExtensionId == "ext_toolkit_2" &&
                                                                                  x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension2 });

                var toolkit = Mocks.Of <IInstalledToolkitInfo>().First(x =>
                                                                       x.Id == "test_toolkit" &&
                                                                       x.Schema.Pattern.Id == Guid.NewGuid() &&
                                                                       x.Schema.Pattern.Views == new[] { viewInfo } &&
                                                                       x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension1, providedExtension2 });

                var patternManager = new Mock <IPatternManager>();

                patternManager.Setup(x => x.InstalledToolkits)
                .Returns(new[] { toolkit, extensionPoint1, extensionPoint2 });

                var serviceProvider = new Mock <IServiceProvider>();

                serviceProvider.Setup(x => x.GetService(typeof(IPatternManager)))
                .Returns(patternManager.Object);

                using (var store = new Microsoft.VisualStudio.Modeling.Store(serviceProvider.Object, typeof(Microsoft.VisualStudio.Modeling.CoreDomainModel), typeof(ProductStateStoreDomainModel)))
                    using (var tx = store.TransactionManager.BeginTransaction())
                    {
                        var productStore = store.ElementFactory.CreateElement <ProductState>();

                        var view = productStore
                                   .CreateProduct(x => { x.ExtensionId = "test_toolkit"; x.DefinitionId = toolkit.Schema.Pattern.Id; })
                                   .CreateView(x => x.DefinitionId = this.viewInfo.Id);

                        this.viewId = view.Id;

                        view.CreateElement(x => x.DefinitionId = this.viewInfo.Elements.ElementAt(2).Id);
                        view.CreateElement(x => x.DefinitionId = this.viewInfo.Elements.ElementAt(2).Id);

                        view.CreateExtension(x => { x.DefinitionId = extensionPoint1.Schema.Pattern.Id; x.ExtensionId = extensionPoint1.Schema.Pattern.ExtensionId; });
                        view.CreateExtension(x => { x.DefinitionId = extensionPoint2.Schema.Pattern.Id; x.ExtensionId = extensionPoint2.Schema.Pattern.ExtensionId; });
                        view.CreateExtension(x => { x.DefinitionId = extensionPoint2.Schema.Pattern.Id; x.ExtensionId = extensionPoint2.Schema.Pattern.ExtensionId; });

                        ProductStateStoreSerializationHelper.Instance.SaveModel(new Microsoft.VisualStudio.Modeling.SerializationResult(), productStore, this.storeFilePath);
                        tx.Commit();
                    }

                this.store = new Microsoft.VisualStudio.Modeling.Store(serviceProvider.Object, typeof(Microsoft.VisualStudio.Modeling.CoreDomainModel), typeof(ProductStateStoreDomainModel));
            }
Пример #38
0
 public AppletInfo(IViewInfo viewInfo)
 {
     this.viewInfo = viewInfo;
 }
Пример #39
0
 public ViewController(ToolsContext context, IViewInfo viewInfo, IViewInfoUI viewInfoUI)
     : base(context, viewInfo, viewInfoUI)
 {
 }
 public ApplicationItemController(GSAppContext context,
                                  IScreenInfo screenInfo,
                                  IViewInfo viewInfo)
     : base(context, screenInfo, viewInfo)
 {
 }
Пример #41
0
 public void SetValuePropertyInfo(IViewInfo view, IColumnInfo p, ValueProperty destination)
 {
     SetValuePropertyInfo(view, view, p, destination);
 }
Пример #42
0
            public void Initialize()
            {
                this.storeFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

                var viewInfoMock = new Mock<IViewInfo>();
                viewInfoMock.Setup(x => x.Id).Returns(Guid.NewGuid());
                viewInfoMock.Setup(e => e.Elements)
                    .Returns(new List<IAbstractElementInfo>
                    {
                        Mocks.Of<IElementInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true),
                        Mocks.Of<ICollectionInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true),
                        Mocks.Of<IElementInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.ZeroToMany)
                    });
                viewInfoMock.Setup(x => x.ExtensionPoints)
                    .Returns(new List<IExtensionPointInfo>
                    {
                        Mocks.Of<IExtensionPointInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.OneToOne && e.AutoCreate == true && e.RequiredExtensionPointId == "ext_1"),
                        Mocks.Of<IExtensionPointInfo>().First(e => e.Id == Guid.NewGuid() && e.Cardinality == Cardinality.ZeroToMany && e.RequiredExtensionPointId == "ext_2"),
                    });

                this.viewInfo = viewInfoMock.Object;

                var providedExtension1 = Mocks.Of<IProvidedExtensionPointInfo>().First(x => x.ExtensionPointId == "ext_1");
                var extensionPoint1 = Mocks.Of<IInstalledToolkitInfo>().First(x =>
                    x.Id == "ext_toolkit_1" &&
                    x.Schema.Pattern.Id == Guid.NewGuid() &&
                    x.Schema.Pattern.ExtensionId == "ext_toolkit_1" &&
                    x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension1 });

                var providedExtension2 = Mocks.Of<IProvidedExtensionPointInfo>().First(x => x.ExtensionPointId == "ext_2");
                var extensionPoint2 = Mocks.Of<IInstalledToolkitInfo>().First(x =>
                    x.Id == "ext_toolkit_2" &&
                    x.Schema.Pattern.Id == Guid.NewGuid() &&
                    x.Schema.Pattern.ExtensionId == "ext_toolkit_2" &&
                    x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension2 });

                var toolkit = Mocks.Of<IInstalledToolkitInfo>().First(x =>
                    x.Id == "test_toolkit" &&
                    x.Schema.Pattern.Id == Guid.NewGuid() &&
                    x.Schema.Pattern.Views == new[] { viewInfo } &&
                    x.Schema.Pattern.ProvidedExtensionPoints == new[] { providedExtension1, providedExtension2 });

                var patternManager = new Mock<IPatternManager>();
                patternManager.Setup(x => x.InstalledToolkits)
                    .Returns(new[] { toolkit, extensionPoint1, extensionPoint2 });

                var serviceProvider = new Mock<IServiceProvider>();
                serviceProvider.Setup(x => x.GetService(typeof(IPatternManager)))
                    .Returns(patternManager.Object);

                using (var store = new Microsoft.VisualStudio.Modeling.Store(serviceProvider.Object, typeof(Microsoft.VisualStudio.Modeling.CoreDomainModel), typeof(ProductStateStoreDomainModel)))
                using (var tx = store.TransactionManager.BeginTransaction())
                {
                    var productStore = store.ElementFactory.CreateElement<ProductState>();

                    var view = productStore
                        .CreateProduct(x => { x.ExtensionId = "test_toolkit"; x.DefinitionId = toolkit.Schema.Pattern.Id; })
                        .CreateView(x => x.DefinitionId = this.viewInfo.Id);

                    this.viewId = view.Id;

                    view.CreateElement(x => x.DefinitionId = this.viewInfo.Elements.ElementAt(2).Id);
                    view.CreateElement(x => x.DefinitionId = this.viewInfo.Elements.ElementAt(2).Id);

                    view.CreateExtension(x => { x.DefinitionId = extensionPoint1.Schema.Pattern.Id; x.ExtensionId = extensionPoint1.Schema.Pattern.ExtensionId; });
                    view.CreateExtension(x => { x.DefinitionId = extensionPoint2.Schema.Pattern.Id; x.ExtensionId = extensionPoint2.Schema.Pattern.ExtensionId; });
                    view.CreateExtension(x => { x.DefinitionId = extensionPoint2.Schema.Pattern.Id; x.ExtensionId = extensionPoint2.Schema.Pattern.ExtensionId; });

                    ProductStateStoreSerializationHelper.Instance.SaveModel(new Microsoft.VisualStudio.Modeling.SerializationResult(), productStore, this.storeFilePath);
                    tx.Commit();
                }

                this.store = new Microsoft.VisualStudio.Modeling.Store(serviceProvider.Object, typeof(Microsoft.VisualStudio.Modeling.CoreDomainModel), typeof(ProductStateStoreDomainModel));
            }
Пример #43
0
 public static void SetDbBindColumn(IViewInfo view, IColumnInfo p, DbBindColumn dbc)
 {
     SetDbBindColumn(view, view, p, dbc);
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="viewManager">View manager</param>
 public DefaultCommandDockingViews( IViewManager viewManager )
 {
     Arguments.CheckNotNull( viewManager, "viewManager" );
     m_ViewManager = viewManager;
     m_RenderTargetsView = new DockingViewInfo( "Render Targets", CreateRenderTargetsViewControl, DefaultCommands.ViewRenderingRenderTargets );
 }
Пример #45
0
 /// <summary>
 /// Adds all view columns to the current object.
 /// </summary>
 /// <param name="view"></param>
 public void AddProperties(IViewInfo view)
 {
     AddProperties(view, view, view.Columns, false, false);
 }
Пример #46
0
 /// <summary>
 /// Adds the specified list of columns from the specified view to the current object.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="selectedColumns"></param>
 public void AddProperties(IViewInfo view, IList <IColumnInfo> selectedColumns)
 {
     AddProperties(view, view, selectedColumns, false, false);
 }
Пример #47
0
 public string GenExistCode(IViewInfo vwInfo)
 {
     return codeGen.Gen(Comm.GetTemplete("View.Exist.cshtml"), vwInfo);
 }