Exemplo n.º 1
0
 public void CreateStatementForTable(CreateStatement createStatement, int rootPage)
 {
     if (this.If_in(createStatement.TableName))
     {
         throw new TableOrIndexAlreadyExistsException("Table Already Exists");
     }
     Models.Table a = new Models.Table(createStatement, rootPage);
     tables.Add(a);
     Save_table(this.tables);
 }
Exemplo n.º 2
0
        internal static void ManageFooterRow(Models.Document document, Models.Table table, Table wordTable, TableLook tableLook, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider)
        {
            // add footer row
            if (table.FooterRow != null)
            {
                wordTable.AppendChild(table.FooterRow.Render(document, wordTable, context, documentPart, false, false, formatProvider));

                tableLook.LastRow = OnOffValue.FromBoolean(true);
            }
        }
Exemplo n.º 3
0
 //try to create one table and save the result into the file
 //if succeed, return true
 //if the table is already created, return false
 public bool TryCreateStatementForTable(CreateStatement createStatement, int rootPage)
 {
     if (this.If_in(createStatement.TableName))
     {
         return(false);
     }
     Models.Table a = new Models.Table(createStatement, rootPage);
     tables.Add(a);
     Save_table(this.tables);
     return(true);
 }
Exemplo n.º 4
0
 internal static void ManageBeforeAfterRows(Models.Document document, Models.Table table, IList <Models.Row> rows, Table wordTable, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider)
 {
     // After rows :
     if (rows != null && rows.Count > 0)
     {
         foreach (var row in rows)
         {
             row.InheritFromParent(table);
             wordTable.AppendChild(row.Render(document, wordTable, context, documentPart, false, false, formatProvider));
         }
     }
 }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Testament,Book,Chapter,Number,Text")] Models.Table verse)
        {
            try
            {
                versesDB1.Tables.Add(verse);
                versesDB1.SaveChanges();

                return(View("Success"));
            }
            catch
            {
                return(View("Failure"));
            }
        }
Exemplo n.º 6
0
        public async Task <Models.Table[]> GetTablesAsync()
        {
            var res = await dynamoDB.ScanAsync(new ScanRequest
            {
                TableName = "Table"
            });

            if (res != null && res.Items != null)
            {
                List <Models.Table> tbs = new List <Models.Table>();
                foreach (var item in res.Items)
                {
                    var tb = new Models.Table {
                        tableName = item["tableName"].S
                    };
                    try
                    {
                        foreach (var name in item["attr"].M)
                        {
                            var a = new Models.Attribute {
                            };
                            a.attrName = name.Key.ToString();
                            a.type     = name.Value.M["type"].S.ToString();
                            a.key      = name.Value.M["key"].S.ToString();

                            if (a.key == "HashKey")
                            {
                                tb.hashKey = a.attrName;
                            }
                            else if (a.key == "RangeKey")
                            {
                                tb.rangeKey = a.attrName;
                            }
                            tb.attr.Add(a);
                        }
                    }catch {
                        tbs.Add(tb);
                        continue;
                    }
                    tbs.Add(tb);
                }
                return(tbs.ToArray());
            }

            return(Array.Empty <Models.Table>());
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            btnSave.Focus();
            if (!btnSave.IsFocused)
            {
                return;
            }
            if (!AllowSave())
            {
                return;
            }
            Models.Table table = new Models.Table();
            table.TableID   = txtTableID.Text;
            table.TableName = txtTableName.Text;
            table.Position  = txtPosition.Text;
            bool bRet = false;

            btnSave.IsEnabled = false;

            if (_fromState == EnumFormState.FormAdd)
            {
                bRet = BLTable.AddTable(table);
            }
            else
            {
                bRet = BLTable.UpdateTable(table);
            }

            if (bRet)
            {
                Lemon3.Messages.L3Msg.SaveOK();
                TableID = txtTableID.Text;
                Close();
                btnSave.IsEnabled = true;
            }
            else
            {
                Lemon3.Messages.L3Msg.SaveNotOK();
                btnSave.IsEnabled = true;
            }
        }
Exemplo n.º 8
0
 public static bool IsTypedTable(this Models.Table obj) => obj?.TypedTable != TypedTableConstants.None;
Exemplo n.º 9
0
 public static bool IsEnumOnly(this Models.Table obj) => obj?.TypedTable == TypedTableConstants.EnumOnly;
Exemplo n.º 10
0
        internal static Tuple <Table, TableLook> CreateTable(Models.Document document, Models.Table table, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider)
        {
            Table wordTable = new Table();

            TableProperties wordTableProperties = new TableProperties();
            var             tableLook           = new TableLook()
            {
                FirstRow         = OnOffValue.FromBoolean(false),
                LastRow          = OnOffValue.FromBoolean(false),
                FirstColumn      = OnOffValue.FromBoolean(false),
                LastColumn       = OnOffValue.FromBoolean(false),
                NoHorizontalBand = OnOffValue.FromBoolean(false),
                NoVerticalBand   = OnOffValue.FromBoolean(false)
            };

            wordTableProperties.AppendChild(tableLook);
            //The type must be Dxa, if the value is set to Pct : the open xml engine will ignored it !
            wordTableProperties.TableIndentation = new TableIndentation()
            {
                Width = table.TableIndentation.Width, Type = TableWidthUnitValues.Dxa
            };
            wordTable.AppendChild(wordTableProperties);

            if (table.Borders != null)
            {
                TableBorders borders = table.Borders.Render();

                wordTableProperties.AppendChild(borders);
            }

            // add column width definitions
            if (table.ColsWidth != null)
            {
                wordTable.AppendChild(new TableLayout()
                {
                    Type = TableLayoutValues.Fixed
                });

                TableGrid tableGrid = new TableGrid();
                foreach (int width in table.ColsWidth)
                {
                    tableGrid.AppendChild(new GridColumn()
                    {
                        Width = width.ToString(CultureInfo.InvariantCulture)
                    });
                }
                wordTable.AppendChild(tableGrid);
            }

            if (table.TableWidth != null)
            {
                wordTable.AppendChild(new TableWidth()
                {
                    Width = table.TableWidth.Width, Type = table.TableWidth.Type.ToOOxml()
                });
            }

            // add header row
            if (table.HeaderRow != null)
            {
                wordTable.AppendChild(table.HeaderRow.Render(document, wordTable, context, documentPart, true, false, formatProvider));

                tableLook.FirstRow = OnOffValue.FromBoolean(true);
            }

            return(new Tuple <Table, TableLook>(wordTable, tableLook));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Render a table element
        /// </summary>
        /// <param name="table"></param>
        /// <param name="parent"></param>
        /// <param name="context"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        public static Table Render(this Models.Table table, Models.Document document, OpenXmlElement parent, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider)
        {
            context.ReplaceItem(table, formatProvider);

            var createdTable = CreateTable(document, table, context, documentPart, formatProvider);
            var wordTable    = createdTable.Item1;
            var tableLook    = createdTable.Item2;

            // Before rows :
            ManageBeforeAfterRows(document, table, table.BeforeRows, wordTable, context, documentPart, formatProvider);

            // add content rows
            if (!string.IsNullOrEmpty(table.DataSourceKey))
            {
                if (context.ExistItem <DataSourceModel>(table.DataSourceKey))
                {
                    var datasource = context.GetItem <DataSourceModel>(table.DataSourceKey);

                    int i = 0;

                    foreach (var item in datasource.Items)
                    {
                        var row = table.RowModel.Clone();
                        row.InheritFromParent(table);

                        if (!string.IsNullOrWhiteSpace(table.AutoContextAddItemsPrefix))
                        {
                            // We add automatic keys :
                            // Is first item
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IsFirstItem#", new BooleanModel(i == 0));
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IsNotFirstItem#", new BooleanModel(i > 0));
                            // Is last item
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IsLastItem#", new BooleanModel(i == datasource.Items.Count - 1));
                            // Index of the element (Based on 0, and based on 1)
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IndexBaseZero#", new StringModel(i.ToString()));
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IndexBaseOne#", new StringModel((i + 1).ToString()));
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IsOdd#", new BooleanModel(i % 2 == 1));
                            item.AddItem("#" + table.AutoContextAddItemsPrefix + "_TableRow_IsEven#", new BooleanModel(i % 2 == 0));
                        }

                        wordTable.AppendChild(row.Render(document, wordTable, item, documentPart, false, (i % 2 == 1), formatProvider));

                        i++;
                    }
                }
            }
            else
            {
                int i = 0;
                foreach (var row in table.Rows)
                {
                    row.InheritFromParent(table);
                    wordTable.AppendChild(row.Render(document, wordTable, context, documentPart, false, (i % 2 == 1), formatProvider));
                    i++;
                }
            }

            // After rows :
            ManageBeforeAfterRows(document, table, table.AfterRows, wordTable, context, documentPart, formatProvider);

            // Footer
            ManageFooterRow(document, table, wordTable, tableLook, context, documentPart, formatProvider);

            parent.AppendChild(wordTable);
            return(wordTable);
        }
Exemplo n.º 12
0
        private void AddBd()
        {
            for (; ;)
            {
                Dictionary <string, string>   Links = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(@"C:\Users\User\Desktop\БИСО-01-17\сенениум\SELENIUMinog\SELENIUMinog\bin\Debug\Links.json"));
                Dictionary <string, string>   Text  = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(@"C:\Users\User\Desktop\БИСО-01-17\сенениум\SELENIUMinog\SELENIUMinog\bin\Debug\Text.json"));
                Dictionary <string, string[]> Img   = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(File.ReadAllText(@"C:\Users\User\Desktop\БИСО-01-17\сенениум\SELENIUMinog\SELENIUMinog\bin\Debug\Img.json"));

                int i = 0;

                string[] LINK = new string[Links.Values.Count];
                string[,] TEXT = new string[2, Links.Keys.Count];
                string[,] IMG  = new string[2, Links.Keys.Count];
                foreach (string c in Links.Values)
                {
                    LINK[i] = c;
                    i++;
                }


                i = 0;
                foreach (string c in Links.Keys)
                {
                    TEXT[0, i] = c;
                    if (Text.ContainsKey(TEXT[0, i]))
                    {
                        TEXT[1, i] = Text[TEXT[0, i]];
                    }
                    else
                    {
                        TEXT[1, i] = null;
                    }
                    i++;
                }


                string value;
                i = 0;
                foreach (string c in Links.Keys)
                {
                    value     = null;
                    IMG[0, i] = c;
                    if (Img.ContainsKey(IMG[0, i]))
                    {
                        for (int j = 0; j < Img[TEXT[0, i]].GetLength(0); j++)
                        {
                            value = value + Img[IMG[0, i]][j] + " ; ";
                        }

                        IMG[1, i] = value;
                    }
                    i++;
                }

                i = 0;
                Models.MyDataBaseEntities db   = new Models.MyDataBaseEntities();
                List <Models.Table>       lst2 = (from t in db.Tables select t).ToList();
                foreach (string c in Links.Keys)
                {
                    Models.Table t1 = new Models.Table()
                    {
                        Id   = c,
                        Link = LINK[i],
                        Text = TEXT[1, i],
                        Img  = IMG[1, i]
                    };
                    db.Tables.Add(t1);
                    db.SaveChanges();
                    i++;
                }

                File.WriteAllText(@"C:\Users\User\Desktop\Новая папка (2)\qwe.txt", "123123123123");
            }
        }