Ejemplo n.º 1
0
        public static IHtmlControl GetDialogueView(SiteState state,
                                                   IDataLayer forumConnection, UserStorage userStorage, LightObject user, out string title)
        {
            title = "Диалоги";

            TableLink dialogueLink = DialogueHlp.LoadDialogueLink(forumConnection,
                                                                  "user_id = @userId order by modify_time desc",
                                                                  new DbParameter("userId", user.Id)
                                                                  );

            IHtmlControl[] messageBlocks = new IHtmlControl[dialogueLink.AllRows.Length];
            int            i             = -1;

            foreach (RowLink dialog in dialogueLink.AllRows)
            {
                ++i;
                messageBlocks[i] = GetDialogBlock(forumConnection, userStorage, user, dialog, i);
            }

            return(new HPanel(
                       Decor.Title("Диалоги"),
                       new HPanel(
                           messageBlocks
                           )
                       ));
        }
Ejemplo n.º 2
0
        public TopicStorage(IDataLayer topicConnection, IDataLayer messageConnection, int topicTypeId, int topicId)
        {
            this.TopicId = topicId;

            this.topicCache = new Cache <LightKin, long>(
                delegate
            {
                return(DataBox.LoadKin(topicConnection, topicTypeId, topicId));
            },
                delegate { return(topicChangeTick); }
                );

            this.messageLinkCache = new Cache <Tuple <TableLink, Dictionary <int, string> >, long>(
                delegate
            {
                TableLink messageLink = MessageHlp.LoadMessageLink(messageConnection, topicId);

                Dictionary <int, string> htmlRepresentById = new Dictionary <int, string>(messageLink.AllRows.Length);
                foreach (RowLink message in messageLink.AllRows)
                {
                    int messageId                = message.Get(MessageType.Id);
                    string content               = message.Get(MessageType.Content);
                    string htmlRepresent         = BasketballHlp.PreViewComment(content);
                    htmlRepresentById[messageId] = htmlRepresent;
                }

                return(_.Tuple(messageLink, htmlRepresentById));
            },
                delegate { return(messageChangeTick); }
                );
        }
Ejemplo n.º 3
0
        public static LinkRequestTable MakeLinkRequest(TableLink metaLink, Table sourceTable, Column sourceColumn, long sourceRow, Database.Operation.ExpressionParsingContext expressionParsingContext)
        {
            if (metaLink == null)
            {
                return(null);
            }
            var lr = new LinkRequestTable();

            lr.LinkToOpen   = metaLink;
            lr.SourceTable  = sourceTable;
            lr.SourceView   = sourceTable as View.ViewTable;
            lr.SourceColumn = sourceColumn;
            lr.SourceRow    = sourceRow;

            if (lr.LinkToOpen.Parameters != null)
            {
                foreach (var p in lr.LinkToOpen.Parameters)
                {
                    var opt            = new Operation.Expression.ParseIdentifierOption(sourceTable.Schema as View.ViewSchema, sourceTable, true, true, typeof(string), expressionParsingContext);
                    var metaExpression = new Operation.Expression.MetaExpression(p.Value, true);
                    var exp            = Operation.Expression.ParseIdentifier(metaExpression, opt);
                    var exp2           = Operation.ColumnCreator.CreateTypedExpressionFixedRow(exp, sourceRow);
                    lr.Parameters.Add(p.Key, exp2);
                }
            }
            return(lr);
        }
Ejemplo n.º 4
0
        public List <TableLink> GetTableLinks()
        {
            var result = new List <TableLink>();
            var tables = GetDiagramTables();
            var order  = 1;

            var links = tables.SelectMany(t => t.Columns, (t, c) => new { Table = t, Column = c })
                        .Where(d => d.Column.IsFk).Select(d => new { d.Table.Name, d.Column.FkTable, d.Column.FkColumn })
                        .Where(l => tables.Any(t => t.Name == l.Name) && tables.Any(t => t.Name == l.FkTable));

            foreach (var link in links)
            {
                var forTable       = tables.First(t => t.Name == link.Name);
                var forColumnIndex = forTable.Columns.FindIndex(c => c.FkTable == link.FkTable && c.FkColumn == link.FkColumn);
                //var forColumn = forTable.Columns.First(c => c.Name == link.FkColumn);
                var primTable = tables.First(t => t.Name == link.FkTable);
                //var primColumn = primTable.Columns.First();

                var tl = new TableLink
                {
                    PrimaryRefId = GenerateObjectId("table_primary", primTable.Id, 0),
                    ForeignRefId = GenerateObjectId("table_foreign", forTable.Id, forColumnIndex),
                    Order        = order++
                };

                result.Add(tl);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public void IdShouldBeCombinationOfMenuAndSelection()
        {
            //Arrange

            //Act
            TableLink lnk = new TableLink("Table text", "Table short text", "Sortcode", "MENU", "SELECTION", "Table description", LinkType.Table, TableStatus.AccessibleToAll, DateTime.Now, DateTime.Now, "2000", "2019", "Table id", PresCategory.Official);

            //Assert
            Assert.AreEqual(lnk.ID.Menu, "MENU");
            Assert.AreEqual(lnk.ID.Selection, "SELECTION");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add table to search index
        /// </summary>
        /// <param name="dbType">Type of database</param>
        /// <param name="item">TableLink object representing the table</param>
        /// <param name="path">Path to table within database</param>
        /// <param name="writer">IndexWriter object</param>
        private void IndexTable(PCAxis.Web.Core.Enums.DatabaseType dbType, TableLink item, string path, IndexWriter writer)
        {
            item.ID.Selection = CleanTableId(item.ID);

            PXModel model = PxModelManager.Current.GetModel(dbType, _database, _language, item.ID);

            if (model != null)
            {
                string   id;
                string   tablePath;
                string   table     = "";
                string   title     = "";
                DateTime published = DateTime.MinValue;

                if (dbType == DatabaseType.PX)
                {
                    char[]        sep    = { '\\' };
                    string[]      parts  = item.ID.Selection.Split(sep, StringSplitOptions.RemoveEmptyEntries);
                    StringBuilder pxPath = new StringBuilder();

                    // PX database
                    id = item.ID.Selection;

                    for (int i = 0; i < parts.Length - 1; i++)
                    {
                        if (i > 0)
                        {
                            pxPath.Append("/");
                        }
                        pxPath.Append(parts[i]);
                    }
                    tablePath = pxPath.ToString();
                    table     = parts.Last();
                    title     = item.Text;
                    if (((TableLink)item).Published != null)
                    {
                        published = (DateTime)((TableLink)item).Published;
                    }
                }
                else
                {
                    // CNMM database
                    id        = item.ID.Selection;
                    tablePath = path;
                    table     = item.ID.Selection;
                    title     = item.Text;
                    if (((TableLink)item).Published != null)
                    {
                        published = (DateTime)((TableLink)item).Published;
                    }
                }
                AddPaxiomDocument(writer, _database, id, tablePath, table, title, published, model.Meta);
            }
        }
Ejemplo n.º 7
0
        public void DropHtmlObjectInDataBase(ref List<Html> htmlObjects)
        {
            int total = htmlObjects.Count;

            for (int c = 0; c < total; c++)
            {
                //----TableLink----
                m_tableLink = new TableLink { Link = htmlObjects[0].Link, Title = htmlObjects[0].Title, VisiteDate = htmlObjects[0].VisiteDate };
                m_dataBase.TableLink.InsertOnSubmit(m_tableLink);
                m_dataBase.SubmitChanges();

                // breakpoint
                string link = htmlObjects[0].Link;
                var req = m_dataBase.TableLink.Where(l => l.Link == link).Take(1);
                int linkId = req.First().Id;

                //----TableH1----
                for (int i = 0; i < htmlObjects[0].ListH1.Count; i++)
                {
                    m_tableH1 = new TableH1 { IdLink = linkId, InnerText = htmlObjects[0].ListH1[i] };
                    m_dataBase.TableH1.InsertOnSubmit(m_tableH1);
                }

                //----TableH2----
                for (int i = 0; i < htmlObjects[0].ListH2.Count; i++)
                {
                    m_tableH2 = new TableH2 { IdLink = linkId, InnerText = htmlObjects[0].ListH2[i] };
                    m_dataBase.TableH2.InsertOnSubmit(m_tableH2);
                }

                //----TableMeta----
                for (int i = 0; i < htmlObjects[0].ListMeta.Count; i++)
                {
                    m_tableMeta = new TableMeta { IdLink = linkId, InnerText = htmlObjects[0].ListMeta[i].Content, Name = htmlObjects[0].ListMeta[i].Name };
                    m_dataBase.TableMeta.InsertOnSubmit(m_tableMeta);
                }

                //----TableEmail----
                for (int i = 0; i < htmlObjects[0].Email.Count; i++)
                {
                    m_tableEmail = new TableEmail { IdLink = linkId, Address = htmlObjects[0].Email[i] };
                    m_dataBase.TableEmail.InsertOnSubmit(m_tableEmail);
                }

                htmlObjects.RemoveAt(0);
            }

            WebLink.LinkVisited.Clear();
            htmlObjects.Clear();
            m_dataBase.SubmitChanges();
        }
Ejemplo n.º 8
0
 public static TableLink LoadUnreadLink(IDataLayer forumConnection)
 {
     return(TableLink.Load(forumConnection,
                           new FieldBlank[] {
         DialogReadType.UserId,
         DialogReadType.Count
     },
                           new IndexBlank[] {
         DialogReadType.UnreadByUserId
     }, "",
                           "Select user_id, count(*) From dialogue",
                           "unread = 1 group by user_id"
                           ));
 }
Ejemplo n.º 9
0
        private TableLink CreateTableLink(PCAxis.Paxiom.PXMeta meta, string path)
        {
            ItemSelection cid = new ItemSelection(System.IO.Path.GetDirectoryName(path.Substring(System.Web.HttpContext.Current.Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath).Length)), path.Substring(System.Web.HttpContext.Current.Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath).Length));
            //TableLink tbl = new TableLink(meta.DescriptionDefault ? meta.Description : meta.Title ?? meta.Description, meta.Matrix, meta.DescriptionDefault ? meta.Description : meta.Title ?? meta.Description, cid.Menu, cid.Selection, meta.Description ?? "",
            //                          LinkType.PX, TableStatus.AccessibleToAll, null, "", "", meta.TableID ?? "",
            //                          PresCategory.Official);


            //TableLink tbl = new TableLink(!string.IsNullOrEmpty(meta.Description) ? meta.Description : meta.Title, meta.Matrix, !string.IsNullOrEmpty(meta.Description) ? meta.Description : meta.Title, path.Substring(System.Web.HttpContext.Current.Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath).Length), meta.Description ?? "",
            //                              LinkType.PX, TableStatus.AccessibleToAll, null, "", "", meta.TableID ?? "",
            //                              PresCategory.Official);

            TableLink tbl = new TableLink(!string.IsNullOrEmpty(meta.Description) ? meta.Description : meta.Title, meta.Matrix, _sortOrder(meta, path), cid.Menu, cid.Selection, meta.Description ?? "", LinkType.PX, TableStatus.AccessibleToAll, null, "", "", meta.TableID ?? "", PresCategory.Official);

            int cellCount = 1;

            for (int i = 0; i < meta.Variables.Count; i++)
            {
                tbl.SetAttribute("Var" + (i + 1) + "Name", meta.Variables[i].Name);
                tbl.SetAttribute("Var" + (i + 1) + "Values", GetNames(meta.Variables[i]));
                tbl.SetAttribute("Var" + (i + 1) + "NumberOfValues", meta.Variables[i].Values.Count.ToString());
                cellCount *= meta.Variables[i].Values.Count;
            }

            System.IO.FileInfo info = new System.IO.FileInfo(path);
            tbl.SetAttribute("size", info.Length);
            tbl.SetAttribute("cells", cellCount.ToString());

            if (meta.AutoOpen)
            {
                tbl.SetAttribute("autoOpen", "true");
            }
            //TODO Use Data format
            //tbl.SetAttribute("updated", info.LastWriteTime.ToString());

            // Store dates in the PC-Axis date format
            tbl.SetAttribute("updated", info.LastWriteTime.ToString(PCAxis.Paxiom.PXConstant.PXDATEFORMAT));
            tbl.SetAttribute("modified", GetLastModified(meta));

            string lastUpdated = GetLastModified(meta);

            if (PxDate.IsPxDate(lastUpdated))
            {
                tbl.LastUpdated = PxDate.PxDateStringToDateTime(lastUpdated);
            }
            tbl.Published = info.LastWriteTime;

            return(tbl);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the CNMM menu object
        /// </summary>
        /// <returns>A Common Nordic Metamodel Menu object</returns>
        private static Item GetCnmmMenu(string dbid, string language, string nodeId, string menuid)
        {
            string    dbLang = language;
            TableLink tblFix = null;
            //Create database objecst to return
            DatamodelMenu menu = ConfigDatamodelMenu.Create(
                dbLang,
                PCAxis.Sql.DbConfig.SqlDbConfigsStatic.DataBases[dbid],
                m =>
            {
                m.RootSelection          = nodeId == "" ? new ItemSelection() : new ItemSelection(menuid, nodeId);
                m.AlterItemBeforeStorage = item =>
                {
                    if (item is TableLink)
                    {
                        TableLink tbl = (TableLink)item;

                        if (string.Compare(tbl.ID.Selection, nodeId, true) == 0)
                        {
                            tblFix = tbl;
                        }
                        if (tbl.StartTime == tbl.EndTime)
                        {
                            tbl.Text = tbl.Text + " " + tbl.StartTime;
                        }
                        else
                        {
                            tbl.Text = tbl.Text + " " + tbl.StartTime + " - " + tbl.EndTime;
                        }

                        if (tbl.Published.HasValue)
                        {
                            tbl.SetAttribute("modified", tbl.Published.Value.ToShortDateString());
                        }
                    }
                    if (String.IsNullOrEmpty(item.SortCode))
                    {
                        item.SortCode = item.Text;
                    }
                };
            });


            return(tblFix != null ? tblFix : menu.CurrentItem);
        }
Ejemplo n.º 11
0
 public static TableLink LoadCorrespondenceLink(IDataLayer forumConnection, string conditionWithoutWhere,
                                                params DbParameter[] conditionParameters)
 {
     return(TableLink.Load(forumConnection,
                           new FieldBlank[] {
         CorrespondenceType.Id,
         CorrespondenceType.UserId,
         CorrespondenceType.CollocutorId,
         CorrespondenceType.Inbox,
         CorrespondenceType.Content,
         CorrespondenceType.CreateTime
     },
                           new IndexBlank[] {
         CorrespondenceType.MessageById
     }, "",
                           "Select id, user_id, collocutor_id, inbox, content, create_time From correspondence",
                           conditionWithoutWhere, conditionParameters
                           ));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Customize the table title
        /// </summary>
        /// <param name="tbl">TableLink object</param>
        /// <param name="showPublished">If published date shall be displayed or not</param>
        private static void CustomizeTableTitle(TableLink tbl, bool showPublished)
        {
            string published = "";

            if (showPublished)
            {
                published = tbl.Published.HasValue ? string.Format("<em> [{0}]</em>", tbl.Published.Value.ToShortDateString()) : "";
            }

            string tableText = tbl.Text;

            try
            {
                if (IsInteger(tbl.Text[tbl.Text.Length - 1].ToString()))
                {
                    tbl.Text = string.Format("{0}{1}", tbl.Text, published);
                }
                else if (tbl.Text[tbl.Text.Length - 1].ToString() == "-") //Specialfall när titeln slutar med streck. Då ska bara s**tår läggas till.
                {
                    tbl.Text = string.Format("{0} {1}{2}", tbl.Text, tbl.EndTime, published);
                }
                else if (tbl.StartTime == tbl.EndTime)
                {
                    tbl.Text = string.Format("{0} {1}{2}", tbl.Text, tbl.StartTime, published);
                }
                else
                {
                    tbl.Text = string.Format("{0} {1} - {2}{3}", tbl.Text, tbl.StartTime, tbl.EndTime, published);
                }
            }
            catch (Exception)
            {
                tbl.Text = tableText;
            }

            //TODO: Mark table with icon if it is updated after it was published

            //if (SSDDatabase.IsTableUpdated(tbl.Selection.Split(':')[1], tbl.Selection.Split(':')[0]))
            //{
            //    var tableIsUpdatedText = Translate("/templates/ssd/treeview/tableupdatedafterpublishing");
            //    tbl.Text += "&nbsp;<img src=\"/Pages/Images/refresh.png\" alt=\"" + tableIsUpdatedText + "\" title=\"" + tableIsUpdatedText + "\"></img>";
            //}
        }
Ejemplo n.º 13
0
 private static void ProcessTableLink(TableLink tl, XmlWriter xmlw)
 {
     xmlw.WriteStartElement("TableLink");
     xmlw.WriteAttributeString("JoinType", tl.JoinType.ToStringSafe());
     xmlw.WriteAttributeString("SourceTableAlias", tl.SourceTableAlias);
     xmlw.WriteAttributeString("TargetTableAlias", tl.TargetTableAlias);
     foreach (string sfn in tl.SourceFieldNames)
     {
         xmlw.WriteStartElement("SourceField");
         xmlw.WriteAttributeString("Name", sfn);
         xmlw.WriteEndElement();
     }
     foreach (string tfn in tl.TargetFieldNames)
     {
         xmlw.WriteStartElement("TargetField");
         xmlw.WriteAttributeString("Name", tfn);
         xmlw.WriteEndElement();
     }
     xmlw.WriteEndElement();
 }
Ejemplo n.º 14
0
 private static void ProcessTableLink(TableLink link, XmlWriter xmlw)
 {
     xmlw.WriteStartElement("TableLink");
     xmlw.WriteAttributeString("JoinType", link.JoinType.ToStringSafe());
     xmlw.WriteAttributeString("SourceTable", link.SourceTable.Name);
     xmlw.WriteAttributeString("DestinationTable", link.DestinationTable.Name);
     foreach (DatabaseFieldDefinition sfld in link.SourceFields)
     {
         xmlw.WriteStartElement("SourceField");
         xmlw.WriteAttributeString("FormulaName", sfld.FormulaName);
         xmlw.WriteEndElement();
     }
     foreach (DatabaseFieldDefinition dfld in link.DestinationFields)
     {
         xmlw.WriteStartElement("DestinationField");
         xmlw.WriteAttributeString("FormulaName", dfld.FormulaName);
         xmlw.WriteEndElement();
     }
     xmlw.WriteEndElement();
 }
Ejemplo n.º 15
0
 public static TableLink LoadDialogueLink(IDataLayer forumConnection, string conditionWithoutWhere,
                                          params DbParameter[] conditionParameters)
 {
     return(TableLink.Load(forumConnection,
                           new FieldBlank[] {
         DialogueType.Id,
         DialogueType.UserId,
         DialogueType.CollocutorId,
         DialogueType.Inbox,
         DialogueType.Content,
         DialogueType.ModifyTime,
         DialogueType.Unread
     },
                           new IndexBlank[] {
         DialogueType.DialogueById
     }, "",
                           "Select id, user_id, collocutor_id, inbox, content, modify_time, unread From dialogue",
                           conditionWithoutWhere, conditionParameters
                           ));
 }
Ejemplo n.º 16
0
 private static void ProcessTableLink(TableLink tl, Utf8JsonWriter jsonw)
 {
     jsonw.WriteStartObject();
     jsonw.WriteString("JoinType", tl.JoinType.ToStringSafe());
     jsonw.WriteString("SourceTableAlias", tl.SourceTableAlias);
     jsonw.WriteString("TargetTableAlias", tl.TargetTableAlias);
     foreach (string sfn in tl.SourceFieldNames)
     {
         jsonw.WritePropertyName("SourceField");
         jsonw.WriteStartObject();
         jsonw.WriteString("Name", sfn);
         jsonw.WriteEndObject();
     }
     foreach (string tfn in tl.TargetFieldNames)
     {
         jsonw.WritePropertyName("TargetField");
         jsonw.WriteStartObject();
         jsonw.WriteString("Name", tfn);
         jsonw.WriteEndObject();
     }
     jsonw.WriteEndObject();
 }
 void ViewColumnNode.IViewColumnNode.SetEntry(long row, Operation.Expression exp, TableLink link)
 {
 }
Ejemplo n.º 18
0
        private Item parseXml(XElement element)
        {
            Item item = null;

            switch (element.Name.ToString())
            {
            case "MenuItem":
                item =
                    new PxMenuItem(
                        this,
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection") != null ? element.Parent.Attribute("selection").Value : "",
                        element.Attribute("selection").Value,
                        element.Element("Description").Value
                        );

                XName[] subItemLabels = new XName[] { "MenuItem", "Headline", "Link" };

                item.Cast <PxMenuItem>().AddSubItemRange(
                    from e in element.Elements()
                    where subItemLabels.Contains(e.Name)
                    select parseXml(e)
                    );

                break;

            case "Headline":
                item =
                    new Headline(
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value
                        );

                break;

            case "Link":
                item =
                    new TableLink(
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value,
                        element.Attribute("type").Value.ToEnum <LinkType>(),
                        element.Attribute("status").Value == "" ? TableStatus.NotSet : (TableStatus)element.Attribute("status").Value[0],
                        element.Element("Published").Value == "" ? null : (DateTime?)DateTime.Parse(element.Element("Published").Value),
                        element.Element("LastUpdated").Value == "" ? null : (DateTime?)DateTime.Parse(element.Element("LastUpdated").Value),
                        element.Element("StartTime").Value,
                        element.Element("EndTime").Value,
                        element.Attribute("tableId").Value,
                        element.Attribute("category").Value == "" ? PresCategory.NotSet : (PresCategory)element.Attribute("category").Value[0]
                        );

                foreach (XElement a in element.Elements("Attribute"))
                {
                    item.Cast <Link>().SetAttribute(a.Attribute("name").Value, a.Value);
                }

                break;

            case "Url":
                item =
                    new Url(
                        element.Element("Text").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value,
                        element.Attribute("category").Value == "" ? PresCategory.NotSet : (PresCategory)element.Attribute("category").Value[0],
                        element.Element("Url").Value,
                        element.Attribute("linkPres").Value == "" ? LinkPres.NotSet : (LinkPres)element.Attribute("linkPres").Value[0]
                        );

                foreach (XElement a in element.Elements("Attribute"))
                {
                    item.Cast <Link>().SetAttribute(a.Attribute("name").Value, a.Value);
                }

                break;

            default:
                break;
            }

            if (item.IsNotOfType <Url>())
            {
                foreach (Url u in element.Elements("Url").Select(e => parseXml(e)))
                {
                    if (u != null)
                    {
                        item.AddUrl(u);
                    }
                }
            }

            item.ID.Menu = element.Parent.Attribute("selection") != null?element.Parent.Attribute("selection").Value : "";

            if (Restriction == null || Restriction(item))
            {
                if (AlterItemBeforeStorage != null)
                {
                    AlterItemBeforeStorage(item);
                }

                return(item);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 19
0
        private Item itemFromRow(DataRow row)
        {
            Item item;

            if (row["PRESENTATION"].ToString().ToUpper() == "P")
            {
                item =
                    new Headline(
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString()
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "table")
            {
                item =
                    new TableLink(
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString(),
                        LinkType.Table,
                        row["TABLESTATUS"].ToString() == "" ? TableStatus.NotSet : (TableStatus)row["TABLESTATUS"].ToString().ToUpper()[0],
                        row["PUBLISHED"].ToString() == "" ? null : (DateTime?)DateTime.Parse(row["PUBLISHED"].ToString()),
                        row["LASTUPDATED"].ToString() == "" ? null : (DateTime?)DateTime.Parse(row["LASTUPDATED"].ToString()),
                        row["STARTTIME"].ToString(),
                        row["ENDTIME"].ToString(),
                        row["TABLEID"].ToString(),
                        row["CATEGORY"].ToString() == "" ? PresCategory.NotSet : (PresCategory)row["CATEGORY"].ToString().ToUpper()[0]
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "menu")
            {
                item =
                    new PxMenuItem(
                        this,
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString()
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "url")
            {
                item =
                    new Url(
                        row["PRESTEXT"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["LINKID"].ToString(),
                        row["DESCRIPTION"].ToString(),
                        (PresCategory)row["CATEGORY"].ToString().ToUpper()[0],
                        row["LINKURL"].ToString(),
                        (LinkPres)row["LINKPRES"].ToString().ToUpper()[0]
                        );
            }
            else
            {
                throw new Exceptions.NotValidItemFromDatabaseException("Row from database not valid for item creation.");
            }

            item.ID.Menu = row["MENU"].ToString();

            if (Restriction(item))
            {
                if (AlterItemBeforeStorage != null)
                {
                    AlterItemBeforeStorage(item);
                }

                return(item);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 20
0
        private static PxMenuBase GetCnmmMenuAndItem(string dbid, string nodeId, string lang, out PCAxis.Menu.Item currentItem)
        {
            //Get selected language in PX-Web
            //string pxLang = PCAxis.Web.Core.Management.LocalizationManager.GetTwoLetterLanguageCode();
            //string dbLang = PxContext.GetCnmmDbLanguage(dbid, pxLang);
            string    dbLang = PxContext.GetCnmmDbLanguage(dbid, lang);
            TableLink tblFix = null;

            //Create database object to return
            DatamodelMenu menu = ConfigDatamodelMenu.Create(
                dbLang,
                PCAxis.Sql.DbConfig.SqlDbConfigsStatic.DataBases[dbid],
                m =>
            {
                m.RootSelection          = string.IsNullOrEmpty(nodeId) ? new ItemSelection() : PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId);
                m.AlterItemBeforeStorage = item =>
                {
                    if (item is PCAxis.Menu.Url)
                    {
                        PCAxis.Menu.Url url = (PCAxis.Menu.Url)item;
                    }

                    if (item is TableLink)
                    {
                        TableLink tbl = (TableLink)item;
                        string tblId  = tbl.ID.Selection;
                        if (!string.IsNullOrEmpty(dbid))
                        {
                            tbl.ID = new ItemSelection(item.ID.Menu, dbid + ":" + tbl.ID.Selection);             // Hantering av flera databaser!
                        }

                        CustomizeTableTitle(tbl, false);

                        if (tbl.Published.HasValue)
                        {
                            // Store date in the PC-Axis date format
                            tbl.SetAttribute("modified", tbl.Published.Value.ToString(PCAxis.Paxiom.PXConstant.PXDATEFORMAT));
                        }
                        if (string.Compare(tblId + item.ID.Menu, PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId).Selection + PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId).Menu, true) == 0)
                        {
                            tblFix = tbl;
                        }
                    }

                    if (String.IsNullOrEmpty(item.SortCode))
                    {
                        item.SortCode = item.Text;
                    }
                };
                m.Restriction = item =>
                {
                    return(true);
                };
            });

            if (tblFix != null)
            {
                currentItem = tblFix;
            }
            else
            {
                currentItem = menu.CurrentItem;
            }

            menu.RootItem.Sort();

            return(menu);
        }
Ejemplo n.º 21
0
 public void NewItem(object item, string path)
 {
     if (item is AliasItem)
     {
         AliasItem alias = (AliasItem)item;
         if (Array.IndexOf(_languages, alias.Language) >= 0)
         {
             if (_currentItems[alias.Language].Text == _currentItems[alias.Language].SortCode)
             {
                 _currentItems[alias.Language].SortCode = alias.Alias;
             }
             _currentItems[alias.Language].Text = alias.Alias;
         }
     }
     else if (item is LinkItem)
     {
         LinkItem itm = (LinkItem)item;
         if (Array.IndexOf(_languages, itm.Language) >= 0)
         {
             if (CheckIfLinkShallBeAdded(path, _currentItems[itm.Language]))
             {
                 //Url url = new Url(itm.Text, "", path, "", PresCategory.NotSet, itm.Location, LinkPres.NotSet);
                 Url url = new Url(itm.Text, "", "MENU_TEST", itm.Location, "", PresCategory.NotSet, itm.Location, LinkPres.NotSet);
                 _currentItems[itm.Language].SubItems.Add(url);
             }
         }
     }
     else if (item is MenuSortItem)
     {
         MenuSortItem sort = item as MenuSortItem;
         if (Array.IndexOf(_languages, sort.Language) >= 0)
         {
             _currentItems[sort.Language].SortCode = sort.SortString;
         }
     }
     else if (item is PCAxis.Paxiom.PXMeta)
     {
         PCAxis.Paxiom.PXMeta meta = (PCAxis.Paxiom.PXMeta)item;
         foreach (var language in _languages)
         {
             if (meta.HasLanguage(language))
             {
                 meta.SetLanguage(language);
                 TableLink tbl = CreateTableLink(meta, path);
                 _currentItems[language].AddSubItem(tbl);
             }
             else
             {
                 if (!_languageDependent)
                 {
                     if (meta.HasLanguage(Settings.Current.General.Language.DefaultLanguage))
                     {
                         meta.SetLanguage(Settings.Current.General.Language.DefaultLanguage);
                     }
                     else
                     {
                         meta.SetLanguage("default");
                     }
                     TableLink tbl = CreateTableLink(meta, path);
                     _currentItems[language].AddSubItem(tbl);
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            if (args.Count() >= 1 && args[0] == "-s")
            {
                Simplified = true;
                args       = args.Skip(1).ToArray();
            }

            if (args.Count() < 1 || args[0] == "-h")
            {
                Console.WriteLine("CrystalReportReaderFramework [-s]  report_file_name.rpt");
                Console.WriteLine("");
                Console.WriteLine("    -s  : Simplify output by removing numbers from sections and text fields and by removing location information.");
                Console.WriteLine("          Simplified output makes it easier to compare reports where layout is not important.");
                Console.WriteLine("");
                return;
            }

            string fileName = args[0];

            ReportDocument reportDocument = new ReportDocument();

            reportDocument.Load(fileName);

            Database db = reportDocument.Database;

            foreach (var t in db.Tables)
            {
                Table  tbl    = t as Table;
                string prefix = "Database:Table:Name:" + tbl.Name + ":";
                Console.WriteLine(prefix);
                Console.WriteLine(prefix + "Location:" + tbl.Location);
                foreach (var f in tbl.Fields)
                {
                    FieldDefinition fd          = f as FieldDefinition;
                    string          fieldPrefix = prefix + "Field:Name:" + fd.Name + ":";
                    Console.WriteLine(fieldPrefix);
                    Console.WriteLine(fieldPrefix + "Kind:" + fd.Kind);
                    Console.WriteLine(fieldPrefix + "ValueType:" + fd.ValueType);
                }
            }

            foreach (var l in db.Links)
            {
                TableLink lnk        = l as TableLink;
                string    linkPRefix = "Database:TableLink:SourceTable:" + lnk.SourceTable.Name + ":DestinationTable:" + lnk.DestinationTable.Name + ":";
                Console.WriteLine(linkPRefix);
                Console.WriteLine(linkPRefix + "JoinType:" + lnk.JoinType);
                for (int i = 0; i < lnk.SourceFields.Count; i++)
                {
                    DatabaseFieldDefinition sfd = lnk.SourceFields[i] as DatabaseFieldDefinition;
                    DatabaseFieldDefinition dfd = lnk.DestinationFields[i] as DatabaseFieldDefinition;
                    Console.WriteLine(linkPRefix + "SourceField:Name:" + sfd.Name + ":DestinationField:Name:" + dfd.Name);
                }
            }


            var ffs = reportDocument.DataDefinition.FormulaFields;

            foreach (var ff in ffs)
            {
                FormulaFieldDefinition ffd = ff as FormulaFieldDefinition;
                Console.WriteLine("Formula:FormulaName:" + ffd.FormulaName + ":");
                if (ffd.Text != null)
                {
                    Console.WriteLine("Formula:FormulaName:" + ffd.FormulaName + ":Text:'" + MakeSingleLine(ffd.Text));
                }
            }

            var rtfs = reportDocument.DataDefinition.RunningTotalFields;

            foreach (var rtf in rtfs)
            {
                RunningTotalFieldDefinition rtfd = rtf as RunningTotalFieldDefinition;
                Group  rc     = rtfd.ResetCondition as Group;
                string prefix = "RunningTotal:FormulaName:" + rtfd.FormulaName + ":";
                Console.WriteLine(prefix + "Operation:" + rtfd.Operation);
                Console.WriteLine(prefix + "SummarizedField:" + rtfd.SummarizedField.Name + "," + rtfd.SummarizedField.FormulaName);
                Console.WriteLine(prefix + "EvaluationCondition:" + rtfd.EvaluationCondition);
                Console.WriteLine(prefix + "ResetCondition:" + rc.ConditionField.FormulaName);
            }


            var groups = reportDocument.DataDefinition.Groups;

            foreach (var gp in groups)
            {
                Group  gpd    = gp as Group;
                string prefix = "Group:GroupName:" + RemoveNumbersIfSimplified(gpd.ConditionField.FormulaName) + ":";
                Console.WriteLine(prefix);
                Console.WriteLine(prefix + "GroupOptions.Condition:" + gpd.GroupOptions.Condition);
            }



            var parameterFields = reportDocument.DataDefinition.ParameterFields;

            foreach (var pf in parameterFields)
            {
                ParameterFieldDefinition pfd = pf as ParameterFieldDefinition;
                var x = "ParameterFields:FormulaName:" + pfd.FormulaName + ":" +
                        "ParameterFieldName:" + pfd.ParameterFieldName;
                Console.WriteLine(x);
            }


            var sections = reportDocument.ReportDefinition.Sections;

            foreach (var section in sections)
            {
                Section sd     = section as Section;
                string  prefix = "Section:Name:" + RemoveNumbersIfSimplified(sd.Name) + ":";
                Console.WriteLine(prefix);
                Console.WriteLine(prefix + "Kind:" + sd.Kind);
                Console.WriteLine(prefix + "EnableKeepTogether:" + sd.SectionFormat.EnableKeepTogether);
                Console.WriteLine(prefix + "EnableSuppress:" + sd.SectionFormat.EnableSuppress);
                if (!Simplified)
                {
                    Console.WriteLine(prefix + "Height:" + sd.Height);
                    Console.WriteLine(prefix + "Height:" + sd.Height);
                }


                AddReportObjects(prefix, sd.ReportObjects);
            }

            // Console.WriteLine(reportDocument);
            //Console.ReadLine();
        }
Ejemplo n.º 23
0
        public static IHtmlControl GetCorrespondenceView(SiteState state,
                                                         IDataLayer forumConnection, LightObject user, LightObject collocutor, out string title)
        {
            title = "Личные сообщения";

            int pageIndex    = state.Option.Get(OptionType.CorrespondencePageIndex);
            int messageCount = DatabaseHlp.RowCount(forumConnection, "", "correspondence",
                                                    "user_id = @userId and collocutor_id = @collocutorId",
                                                    new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                    );
            int pageCount = BinaryHlp.RoundUp(messageCount, 5);

            HButton prevButton = null;

            if (pageCount - 1 > pageIndex)
            {
                prevButton = Decor.ButtonMidi("предыдущие").Event("page_prev", "",
                                                                  delegate
                {
                    state.Option.Set(OptionType.CorrespondencePageIndex, pageIndex + 1);
                }
                                                                  );
            }

            HButton nextButton = null;

            if (pageIndex > 0)
            {
                nextButton = Decor.ButtonMidi("следующие").Event("page_next", "",
                                                                 delegate
                {
                    state.Option.Set(OptionType.CorrespondencePageIndex, pageIndex - 1);
                }
                                                                 );
            }

            TableLink messageLink = DialogueHlp.LoadCorrespondenceLink(forumConnection,
                                                                       string.Format("user_id = @userId and collocutor_id = @collocutorId order by create_time desc limit 5 offset {0}",
                                                                                     pageIndex * 5
                                                                                     ),
                                                                       new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                                       );

            RowLink[]           messages      = messageLink.AllRows;
            List <IHtmlControl> messageBlocks = new List <IHtmlControl>();

            if (prevButton != null || nextButton != null)
            {
                messageBlocks.Add(
                    new HPanel(
                        new HPanel(prevButton), new HPanel(nextButton)
                        ).MarginTop(5).MarginBottom(5)
                    );
            }

            for (int i = messages.Length - 1; i >= 0; --i)
            {
                //if (i == 2)
                //  messageBlocks.Add(new HAnchor("bottom"));

                messageBlocks.Add(GetMessageBlock(forumConnection, state, user, collocutor, messages[i], i));
            }

            IHtmlControl addPanel = GetAddPanel(context, state, user, collocutor, false);

            return(new HPanel(
                       GetCorrespondenceHeader(state, user, collocutor),
                       new HPanel(
                           messageBlocks.ToArray()
                           ).BorderBottom(Decor.bottomBorder),
                       addPanel
                       ));
        }
Ejemplo n.º 24
0
        private string ConvertXdf(XDocument doc)
        {
            string retVal = "";

            try
            {
                //List<string> categories = new List<string>();
                Dictionary <int, string> categories   = new Dictionary <int, string>();
                List <TableLink>         tableLinks   = new List <TableLink>();
                List <TableLink>         tableTargets = new List <TableLink>();

                foreach (XElement element in doc.Elements("XDFFORMAT").Elements("XDFHEADER"))
                {
                    foreach (XElement cat in element.Elements("CATEGORY"))
                    {
                        string catTxt = cat.Attribute("name").Value;
                        int    catId  = Convert.ToInt32(cat.Attribute("index").Value.Replace("0x", ""), 16);
                        categories.Add(catId, catTxt);
                    }
                }
                foreach (XElement element in doc.Elements("XDFFORMAT").Elements("XDFTABLE"))
                {
                    TableData xdf = new TableData();
                    xdf.OS     = PCM.OS;
                    xdf.Origin = "xdf";
                    xdf.Min    = double.MinValue;
                    xdf.Max    = double.MaxValue;
                    string RowHeaders  = "";
                    string ColHeaders  = "";
                    string size        = "";
                    string math        = "";
                    int    elementSize = 0;
                    bool   Signed      = false;
                    bool   Floating    = false;

                    List <string> multiMath = new List <string>();
                    List <string> multiAddr = new List <string>();

                    foreach (XElement axle in element.Elements("XDFAXIS"))
                    {
                        if (axle.Attribute("id").Value == "x")
                        {
                            xdf.Columns = Convert.ToUInt16(axle.Element("indexcount").Value);
                            foreach (XElement lbl in axle.Elements("LABEL"))
                            {
                                ColHeaders += lbl.Attribute("value").Value + ",";
                            }
                            ColHeaders        = ColHeaders.Trim(',');
                            xdf.ColumnHeaders = ColHeaders;
                        }
                        if (axle.Attribute("id").Value == "y")
                        {
                            xdf.Rows = Convert.ToUInt16(axle.Element("indexcount").Value);
                            foreach (XElement lbl in axle.Elements("LABEL"))
                            {
                                RowHeaders += lbl.Attribute("value").Value + ",";
                            }
                            RowHeaders     = RowHeaders.Trim(',');
                            xdf.RowHeaders = RowHeaders;
                        }
                        if (axle.Attribute("id").Value == "z")
                        {
                            if (axle.Element("EMBEDDEDDATA").Attribute("mmedaddress") != null)
                            {
                                xdf.Address = axle.Element("EMBEDDEDDATA").Attribute("mmedaddress").Value.Trim();
                            }
                            //xdf.addrInt = Convert.ToUInt32(addr, 16);
                            string tmp = axle.Element("EMBEDDEDDATA").Attribute("mmedelementsizebits").Value.Trim();
                            size        = (Convert.ToInt32(tmp) / 8).ToString();
                            elementSize = (byte)(Convert.ToInt32(tmp) / 8);
                            math        = axle.Element("MATH").Attribute("equation").Value.Trim().Replace("*.", "*0.");
                            xdf.Math    = math.Replace("/.", "/0.").ToLower();
                            xdf.Math    = xdf.Math.Replace("+ -", "-").Replace("+-", "-").Replace("++", "+").Replace("+ + ", "+");
                            //xdf.SavingMath = convertMath(xdf.Math);
                            xdf.Decimals = Convert.ToUInt16(axle.Element("decimalpl").Value);
                            if (axle.Element("outputtype") != null)
                            {
                                xdf.OutputType = (OutDataType)Convert.ToUInt16(axle.Element("outputtype").Value);
                            }
                            if (axle.Element("EMBEDDEDDATA") != null && axle.Element("EMBEDDEDDATA").Attribute("mmedtypeflags") != null)
                            {
                                byte flags = Convert.ToByte(axle.Element("EMBEDDEDDATA").Attribute("mmedtypeflags").Value, 16);
                                Signed = Convert.ToBoolean(flags & 1);
                                if ((flags & 0x10000) == 0x10000)
                                {
                                    Floating = true;
                                }
                                else
                                {
                                    Floating = false;
                                }
                                if ((flags & 4) == 4)
                                {
                                    xdf.RowMajor = false;
                                }
                                else
                                {
                                    xdf.RowMajor = true;
                                }
                            }

                            foreach (XElement rowMath in axle.Elements("MATH"))
                            {
                                if (rowMath.Element("VAR").Attribute("address") != null)
                                {
                                    //Table have different address for every (?) row
                                    Debug.WriteLine(rowMath.Element("VAR").Attribute("address").Value);
                                    Debug.WriteLine(rowMath.Attribute("equation").Value);
                                    multiAddr.Add(rowMath.Element("VAR").Attribute("address").Value);
                                    multiMath.Add(rowMath.Attribute("equation").Value);
                                }
                                foreach (XElement mathVar in rowMath.Elements("VAR"))
                                {
                                    if (mathVar.Attribute("id") != null)
                                    {
                                        string mId = mathVar.Attribute("id").Value.ToLower();
                                        if (mId != "x")
                                        {
                                            if (mathVar.Attribute("type") != null && mathVar.Attribute("type").Value == "link")
                                            {
                                                //Get math values from other table
                                                string    linktable = mathVar.Attribute("linkid").Value;
                                                TableLink tl        = new TableLink();
                                                tl.tdId     = tdList.Count;
                                                tl.variable = mId;
                                                tl.xdfId    = linktable;
                                                tableLinks.Add(tl);
                                            }
                                            if (mathVar.Attribute("type") != null && mathVar.Attribute("type").Value == "address")
                                            {
                                                string addrStr  = mathVar.Attribute("address").Value.ToLower().Replace("0x", "");
                                                string bits     = "8";
                                                bool   lsb      = false;
                                                bool   isSigned = false;
                                                if (mathVar.Attribute("sizeinbits") != null)
                                                {
                                                    bits = mathVar.Attribute("sizeinbits").Value;
                                                }
                                                if (mathVar.Attribute("flags") != null)
                                                {
                                                    byte flags = Convert.ToByte(mathVar.Attribute("flags").Value, 16);
                                                    isSigned = Convert.ToBoolean(flags & 1);
                                                    if ((flags & 4) == 4)
                                                    {
                                                        lsb = true;
                                                    }
                                                    else
                                                    {
                                                        lsb = false;
                                                    }
                                                }
                                                InDataType idt        = convertToDataType(bits, isSigned, false);
                                                string     replaceStr = "raw:" + addrStr + ":" + idt.ToString();
                                                if (lsb)
                                                {
                                                    replaceStr += ":lsb ";
                                                }
                                                else
                                                {
                                                    replaceStr += ":msb ";
                                                }
                                                xdf.Math = xdf.Math.Replace(mId, replaceStr);
                                                xdf.Math = xdf.Math.Replace("+ -", "-").Replace("+-", "-").Replace("++", "+").Replace("+ + ", "+");
                                                //xdf.SavingMath = xdf.SavingMath.Replace(mId, replaceStr);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    xdf.TableName = element.Element("title").Value;
                    if (element.Element("units") != null)
                    {
                        xdf.Units = element.Element("units").Value;
                    }

                    /*if (element.Element("datatype") != null)
                     *  xdf.DataType = Convert.ToByte(element.Element("datatype").Value);*/
                    if (element.Element("CATEGORYMEM") != null && element.Element("CATEGORYMEM").Attribute("category") != null)
                    {
                        int catid = 0;
                        foreach (XElement catEle in element.Elements("CATEGORYMEM"))
                        {
                            catid = Convert.ToInt16(catEle.Attribute("category").Value);
                            Debug.WriteLine(catid);
                            if (xdf.Category.Length > 0)
                            {
                                xdf.Category += " - ";
                            }
                            xdf.Category += categories[catid - 1];
                        }
                    }
                    if (element.Element("description") != null)
                    {
                        xdf.TableDescription = element.Element("description").Value;
                    }
                    xdf.DataType = convertToDataType(elementSize, Signed, Floating);

                    if (multiMath.Count > 0 && xdf.Rows == multiMath.Count)
                    {
                        string[] rowHdr = xdf.RowHeaders.Replace(".", "").Split(',');
                        for (int m = 0; m < multiMath.Count; m++)
                        {
                            TableData tdNew = new TableData();
                            tdNew         = xdf.ShallowCopy();
                            tdNew.Rows    = 1; //Convert to single-row, multitable
                            tdNew.Math    = multiMath[m];
                            tdNew.Address = multiAddr[m];
                            if (rowHdr.Length >= m - 1)
                            {
                                tdNew.TableName += "." + rowHdr[m];
                            }
                            else
                            {
                                tdNew.TableName += "." + m.ToString();
                            }
                            tdList.Add(tdNew);
                        }
                    }
                    else
                    {
                        tdList.Add(xdf);
                    }
                }
                foreach (XElement element in doc.Elements("XDFFORMAT").Elements("XDFCONSTANT"))
                {
                    TableData xdf = new TableData();
                    xdf.OS     = PCM.OS;
                    xdf.Origin = "xdf";
                    xdf.Min    = double.MinValue;
                    xdf.Max    = double.MaxValue;
                    int  elementSize = 0;
                    bool Signed      = false;
                    bool Floating    = false;
                    if (element.Attribute("uniqueid") != null)
                    {
                        TableLink tl = new TableLink();
                        tl.xdfId = element.Attribute("uniqueid").Value;
                        tl.tdId  = tdList.Count;
                        tableTargets.Add(tl);
                    }
                    if (element.Element("EMBEDDEDDATA").Attribute("mmedaddress") != null)
                    {
                        xdf.TableName = element.Element("title").Value;
                        //xdf.AddrInt = Convert.ToUInt32(element.Element("EMBEDDEDDATA").Attribute("mmedaddress").Value.Trim(), 16);
                        xdf.Address = element.Element("EMBEDDEDDATA").Attribute("mmedaddress").Value.Trim();
                        elementSize = (byte)(Convert.ToInt32(element.Element("EMBEDDEDDATA").Attribute("mmedelementsizebits").Value.Trim()) / 8);
                        xdf.Math    = element.Element("MATH").Attribute("equation").Value.Trim().Replace("*.", "*0.").Replace("/.", "/0.");
                        xdf.Math    = xdf.Math.Replace("+ -", "-").Replace("+-", "-").Replace("++", "+").Replace("+ + ", "+");
                        //xdf.SavingMath = convertMath(xdf.Math);
                        if (element.Element("units") != null)
                        {
                            xdf.Units = element.Element("units").Value;
                        }
                        if (element.Element("EMBEDDEDDATA").Attribute("mmedtypeflags") != null)
                        {
                            byte flags = Convert.ToByte(element.Element("EMBEDDEDDATA").Attribute("mmedtypeflags").Value, 16);
                            Signed = Convert.ToBoolean(flags & 1);
                            if ((flags & 0x10000) == 0x10000)
                            {
                                Floating = true;
                            }
                            else
                            {
                                Floating = false;
                            }
                        }
                        xdf.Columns  = 1;
                        xdf.Rows     = 1;
                        xdf.RowMajor = false;
                        if (element.Element("CATEGORYMEM") != null && element.Element("CATEGORYMEM").Attribute("category") != null)
                        {
                            int catid = 0;
                            foreach (XElement catEle in element.Elements("CATEGORYMEM"))
                            {
                                catid = Convert.ToInt16(catEle.Attribute("category").Value);
                                if (xdf.Category.Length > 0)
                                {
                                    xdf.Category += " - ";
                                }
                                xdf.Category += categories[catid - 1];
                            }
                        }
                        if (element.Element("description") != null)
                        {
                            xdf.TableDescription = element.Element("description").Value;
                        }
                        xdf.DataType = convertToDataType(elementSize, Signed, Floating);

                        tdList.Add(xdf);
                    }
                }
                foreach (XElement element in doc.Elements("XDFFORMAT").Elements("XDFFLAG"))
                {
                    TableData xdf = new TableData();
                    xdf.OS     = PCM.OS;
                    xdf.Origin = "xdf";
                    xdf.Min    = double.MinValue;
                    xdf.Max    = double.MaxValue;
                    if (element.Element("EMBEDDEDDATA").Attribute("mmedaddress") != null)
                    {
                        xdf.TableName = element.Element("title").Value;
                        //xdf.AddrInt = Convert.ToUInt32(element.Element("EMBEDDEDDATA").Attribute("mmedaddress").Value.Trim(), 16);
                        xdf.Address = element.Element("EMBEDDEDDATA").Attribute("mmedaddress").Value.Trim();
                        int elementSize = (byte)(Convert.ToInt32(element.Element("EMBEDDEDDATA").Attribute("mmedelementsizebits").Value.Trim()) / 8);
                        xdf.Math       = "X";
                        xdf.BitMask    = element.Element("mask").Value;
                        xdf.OutputType = OutDataType.Flag;
                        xdf.Columns    = 1;
                        xdf.Rows       = 1;
                        xdf.RowMajor   = false;
                        if (element.Element("CATEGORYMEM") != null && element.Element("CATEGORYMEM").Attribute("category") != null)
                        {
                            int catid = 0;
                            foreach (XElement catEle in element.Elements("CATEGORYMEM"))
                            {
                                catid = Convert.ToInt16(catEle.Attribute("category").Value);
                                if (xdf.Category.Length > 0)
                                {
                                    xdf.Category += " - ";
                                }
                                xdf.Category += categories[catid - 1];
                            }
                        }
                        if (element.Element("description") != null)
                        {
                            xdf.TableDescription = element.Element("description").Value;
                        }
                        xdf.DataType = convertToDataType(elementSize, false, false);
                        tdList.Add(xdf);
                    }
                }
                for (int i = 0; i < tableLinks.Count; i++)
                {
                    TableLink tl     = tableLinks[i];
                    TableData linkTd = tdList[tl.tdId];
                    for (int t = 0; t < tableTargets.Count; t++)
                    {
                        if (tableTargets[t].xdfId == tl.xdfId)
                        {
                            TableData targetTd = tdList[tableTargets[t].tdId];
                            linkTd.Math = linkTd.Math.Replace(tl.variable, "TABLE:'" + targetTd.TableName + "'");
                            //linkTd.SavingMath = linkTd.SavingMath.Replace(tl.variable, "TABLE:'" + targetTd.TableName + "'");
                            break;
                        }
                    }
                }

                for (int i = 0; i < PCM.tableDatas.Count; i++)
                {
                    if (!PCM.tableCategories.Contains(PCM.tableDatas[i].Category))
                    {
                        PCM.tableCategories.Add(PCM.tableDatas[i].Category);
                    }
                }
            }
            catch (Exception ex)
            {
                var st = new StackTrace(ex, true);
                // Get the top stack frame
                var frame = st.GetFrame(st.FrameCount - 1);
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                retVal += "XdfImport, line " + line + ": " + ex.Message + Environment.NewLine;
            }
            return(retVal);
        }
Ejemplo n.º 25
0
 void ViewColumnNode.IViewColumnNode.SetEntry(long row, Operation.Expression exp, TableLink link)
 {
     m_Cache.SetEntryDirty((int)row);
     entries[(int)row]     = exp as Operation.TypedExpression <DataT>;
     linkEntries[(int)row] = link;
 }
Ejemplo n.º 26
0
        private TableLink CreateTableLink(PCAxis.Paxiom.PXMeta meta, string path)
        {

            ItemSelection cid = new ItemSelection(System.IO.Path.GetDirectoryName(path.Substring(_rootPath.Length)), path.Substring(_rootPath.Length));

            TableLink tbl = new TableLink(!string.IsNullOrEmpty(meta.Description) ? meta.Description : meta.Title, meta.Matrix, _sortOrder(meta, path), cid.Menu, cid.Selection, meta.Description ?? "", LinkType.PX, TableStatus.AccessibleToAll, null, "", "", meta.TableID ?? "", PresCategory.Official);

            int cellCount = 1;
            for (int i = 0; i < meta.Variables.Count; i++)
            {
                tbl.SetAttribute("Var" + (i + 1) + "Name", meta.Variables[i].Name);
                tbl.SetAttribute("Var" + (i + 1) + "Values", GetNames(meta.Variables[i]));
                tbl.SetAttribute("Var" + (i + 1) + "NumberOfValues", meta.Variables[i].Values.Count.ToString());
                cellCount *= meta.Variables[i].Values.Count;
            }

            System.IO.FileInfo info = new System.IO.FileInfo(path);
            tbl.SetAttribute("size", info.Length);
            tbl.SetAttribute("cells", cellCount.ToString());

            if (meta.AutoOpen)
            {
                tbl.SetAttribute("autoOpen", "true");
            }
            //TODO Use Data format
            //tbl.SetAttribute("updated", info.LastWriteTime.ToString());

            // Store dates in the PC-Axis date format
            tbl.SetAttribute("updated", info.LastWriteTime.ToString(PCAxis.Paxiom.PXConstant.PXDATEFORMAT));
            tbl.SetAttribute("modified", GetLastModified(meta));

            string lastUpdated = GetLastModified(meta);
            if (PxDate.IsPxDate(lastUpdated))
            {
                tbl.LastUpdated = PxDate.PxDateStringToDateTime(lastUpdated);
            }
            tbl.Published = info.LastWriteTime;

            return tbl;
        }