Represent a list which could be a numbered or bullet style list.
상속: IContent, IContentContainer, IHtml
예제 #1
0
 public void BulletListTest()
 {
     //Create a new text document
     var document					= new TextDocument();
     document.New();
     //Create a bullet list
     var li = new AODL.Document.Content.Text.List(document, "L1", ListStyles.Bullet, "L1P1");
     Assert.IsNotNull(li.Node, "Node object must exist!");
     Assert.IsNotNull(li.Style, "Style object must exist!");
     Assert.IsNotNull(li.ListStyle.ListlevelStyles, "ListLevelStyleCollection must exist!");
     Assert.IsTrue(li.ListStyle.ListlevelStyles.Count == 10, "Must exist exactly 10 ListLevelStyle objects!");
     Assert.IsNotNull(li.ListStyle.ListlevelStyles[1].ListLevelProperties, "ListLevelProperties object must exist!");
 }
예제 #2
0
        /// <summary>
        /// Creates sublists for nested lists.
        /// </summary>
        /// <param name="firstItem">The item to start the list with.</param>
        /// <param name="document">The document to which the sublist belongs.</param>
        /// <param name="currentIndex">The index of the item.</param>
        /// <returns>An ODF list</returns>
        protected AODL.Document.Content.Text.List GetODFSublist(ListItem firstItem, IDocument document, AODL.Document.Content.Text.List parentList, ref int currentIndex)
        {
            //Create a list
            AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, parentList);

            //Set the level of the list
            int currentLevel = firstItem.Level;

            //Create a new list item
            AODL.Document.Content.Text.ListItem listItem = null;
            //Loop through the items
            while (currentIndex < Items.Count)
            {
                if (Items[currentIndex].Level > currentLevel)
                {
                    //Start a new list and append items.
                    listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex));
                    continue;
                }
                if (Items[currentIndex].Level < currentLevel)
                {
                    //Stop this list.
                    break;
                }
                if (Items[currentIndex].Level == currentLevel)
                {
                    //Create a new list item
                    listItem = new AODL.Document.Content.Text.ListItem(document);
                    //Create a paragraph
                    var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    //Add the text
                    foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text))
                    {
                        paragraph.TextContent.Add(formatedText);
                    }

                    //Add paragraph to the list item
                    listItem.Content.Add(paragraph);

                    //Add the list item
                    list.Content.Add(listItem);

                    currentIndex++;
                }
            }

            return(list);
        }
예제 #3
0
        /// <summary>
        /// Gets a list in ODF format.
        /// </summary>
        /// <param name="document">The document to which the list belongs.</param>
        /// <returns>The list as an IContent document</returns>
        public override IContent GetODFList(IDocument document)
        {
            //Create a list
            AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, "NL1", ListStyles.Number, "NL1P1");

            //Set the list level to 0 as this is the top of the list
            int currentLevel = 0;

            //Create a new list item
            AODL.Document.Content.Text.ListItem listItem = null;
            //Loop through the items
            for (int currentIndex = 0; currentIndex < Items.Count; currentIndex++)
            {
                if (Items[currentIndex].Level > currentLevel)
                {
                    //Start a new list and append items.
                    if (listItem == null)
                    {
                        listItem = new AODL.Document.Content.Text.ListItem(document);
                    }
                    listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex));
                    currentIndex--;
                    //Skip the rest of the routine
                    continue;
                }
                if (Items[currentIndex].Level == currentLevel)
                {
                    //Create a new list item
                    listItem = new AODL.Document.Content.Text.ListItem(document);
                    //Create a paragraph
                    var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    //Add the text
                    foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text))
                    {
                        paragraph.TextContent.Add(formatedText);
                    }

                    //Add paragraph to the list item
                    listItem.Content.Add(paragraph);

                    //Add the list item
                    list.Content.Add(listItem);
                }
            }

            return(list);
        }
예제 #4
0
 public void ListItemTest()
 {
     //Create a new text document
     var document					= new TextDocument();
     document.New();
     //Create a numbered list
     var li									= new AODL.Document.Content.Text.List(document, "L1", ListStyles.Bullet, "L1P1");
     //Create a new list item
     var lit							= new ListItem(li);
     Assert.IsNotNull(lit.Content, "Content object must exist!");
     //Create a paragraph
     var paragraph						= ParagraphBuilder.CreateStandardTextParagraph(document);
     //Add some text
     paragraph.TextContent.Add(new SimpleText(document, "First item"));
     //Add paragraph to the list item
     lit.Content.Add(paragraph);
     //Add the list item
     li.Content.Add(lit);
     //Add the list
     document.Content.Add(li);
     //Save document
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"list.odt");
 }
예제 #5
0
        /// <summary>
        /// Convert the spreadsheet to a dataset
        /// </summary>
        /// <param name="withEventThrowing"></param>
        /// <returns></returns>
        private DataSet _ConvertSpreadsheetToDataset(bool withEventThrowing)
        {
            int count = 0;
            DataSet data = new DataSet();

            try {
                if(this._doc.TableCount > 0) {
                    int percentMax = 50;
                    double addValue = 0;
                    double throwValue = 0;

                    if(withEventThrowing) {
                        addValue = Convert.ToDouble(
                            Convert.ToDouble(percentMax) / Convert.ToDouble(this._allObjectsInFile)
                        );
                    }

                    // only for my videos !!!!!!!!!!!!!!!!!!!!!!!
                    bool isMy = false;
                    FileInfo fi = new FileInfo(this._filename);
                    if(fi.Name == "Videos.ods") {
                        isMy = true;
                    }

                    TableCollection col = this._doc.TableCollection;

                    foreach(Table tbl in col) {
                        // add a table to the dataset for each
                        // table in the document table collection
                        data.Tables.Add(new DataTable());

                        /*
                         * load column info
                         * */
                        List<ImportTableColumnSettings> list = new List<ImportTableColumnSettings>();

                        RowCollection rc = tbl.RowCollection;

                        foreach(Row r in rc) {
                            if(count < 2) {
                                CellCollection typecc = r.CellCollection;

                                foreach(Cell c in typecc) {
                                    if(count == 0) {
                                        list.Add(new ImportTableColumnSettings());

                                        list[r.GetCellIndex(c)].Index = r.GetCellIndex(c);
                                        list[r.GetCellIndex(c)].Name = c.Node.InnerText;

                                        if(withEventThrowing) {
                                            throwValue += addValue;

                                            if(throwValue <= percentMax) {
                                                this.PercentState(this, new ImportStateEventArgs(throwValue));
                                            }
                                        }
                                        else {
                                            this._allObjectsInFile++;
                                        }
                                    }
                                    else if(count == 1) {
                                        //try {
                                        //    if(c.OfficeValueType != null) {
                                        //        switch(c.OfficeValueType.Trim()) {
                                        //            case "string":
                                        //                list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                        //                break;

                                        //            case "float":
                                        //                list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.Single");
                                        //                break;

                                        //            case "bool":
                                        //                list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.Boolean");
                                        //                break;

                                        //            default:
                                        //                list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                        //                break;
                                        //        }
                                        //    }
                                        //    else {
                                        //        list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                        //    }
                                        //}
                                        //catch(Exception) {
                                        //    list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                        //}

                                        if(isMy && ( r.GetCellIndex(c) == 3 || r.GetCellIndex(c) == 5 )) {
                                            list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.Boolean");
                                        }
                                        else {
                                            try {
                                                if(c.OfficeValueType != null) {
                                                    switch(c.OfficeValueType.Trim()) {
                                                        case "string":
                                                            list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                                            break;

                                                        case "float":
                                                            list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.Single");
                                                            break;

                                                        default:
                                                            list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                                            break;
                                                    }
                                                }
                                                else {
                                                    list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                                }
                                            }
                                            catch(Exception) {
                                                list[r.GetCellIndex(c)].CellDataType = Type.GetType("System.String");
                                            }
                                        }
                                    }
                                    else {
                                        break;
                                    }
                                }
                            }
                            else {
                                break;
                            }

                            count++;
                        }

                        //// genre
                        //ImportTableColumnSettings genre = new ImportTableColumnSettings();
                        //genre.CellDataType = Type.GetType("System.String");
                        //genre.Name = "__GENRE";
                        //list.Add(genre);

                        //// actor
                        //ImportTableColumnSettings actor = new ImportTableColumnSettings();
                        //actor.CellDataType = Type.GetType("System.String");
                        //actor.Name = "__ACTOR";
                        //list.Add(actor);

                        //// director
                        //ImportTableColumnSettings director = new ImportTableColumnSettings();
                        //director.CellDataType = Type.GetType("System.String");
                        //director.Name = "__DIRECTOR";
                        //list.Add(director);

                        //// producer
                        //ImportTableColumnSettings producer = new ImportTableColumnSettings();
                        //producer.CellDataType = Type.GetType("System.String");
                        //producer.Name = "__PRODUCER";
                        //list.Add(producer);

                        //if(withEventThrowing) {
                        //    throwValue += addValue;

                        //    if(throwValue <= percentMax) {
                        //        this.PercentState(this, new ImportStateEventArgs(throwValue);
                        //    }
                        //}
                        //else {
                        //    this._allObjectsInFile++;
                        //}

                        count = 0;
                        int amountOfRealColumns = 0;

                        /*
                         * create dataset columns
                         * */
                        foreach(ImportTableColumnSettings itcs in list) {
                            if(itcs.IsRealObject) {
                                data.Tables[0].Columns.Add(
                                    new DataColumn(
                                        itcs.Name,
                                        (itcs.CellDataType == null ? Type.GetType("System.String") : itcs.CellDataType)
                                    )
                                );

                                if(withEventThrowing) {
                                    throwValue += addValue;

                                    if(throwValue <= percentMax) {
                                        this.PercentState(this, new ImportStateEventArgs(throwValue));
                                    }
                                }
                                else {
                                    this._allObjectsInFile++;
                                }

                                amountOfRealColumns++;
                            }
                        }

                        /*
                         * load data from rows
                         * */
                        foreach(Row r in rc) {
                            if(count > 0) {
                                // cells
                                CellCollection cc = r.CellCollection;

                                try {
                                    // add rows to dataset
                                    DataRow row = data.Tables[0].NewRow();

                                    foreach(Cell c in cc) {
                                        if(r.GetCellIndex(c) < amountOfRealColumns) {
                                            // temp variables
                                            float tmp_float = 0;

                                            // save data
                                            if(isMy && (r.GetCellIndex(c) == 3 || r.GetCellIndex(c) == 5)) {
                                                if(c.Node.InnerText != null
                                                && c.Node.InnerText.Trim() != ""
                                                && (c.Node.InnerText.Trim().ToLower() == "x"
                                                || c.Node.InnerText.Trim().IsExpressionTrue() )) {
                                                    row[r.GetCellIndex(c)] = true;
                                                }
                                                else {
                                                    row[r.GetCellIndex(c)] = false;
                                                }
                                            }
                                            else {
                                                try {
                                                    if(c.OfficeValueType != null) {
                                                        switch(c.OfficeValueType) {
                                                            case "string":
                                                                //row[r.GetCellIndex(c)] = c.Node.InnerText;
                                                                foreach(Paragraph p in c.Content) {
                                                                    foreach(SimpleText text in p.TextContent) {
                                                                        row[r.GetCellIndex(c)] = text.Text;
                                                                    }
                                                                }
                                                                break;

                                                            case "float":
                                                                foreach(Paragraph p in c.Content) {
                                                                    foreach(SimpleText text in p.TextContent) {
                                                                        //row[r.GetCellIndex(c)] = text.Text;
                                                                        float.TryParse(text.Text, out tmp_float);
                                                                    }
                                                                }

                                                                row[r.GetCellIndex(c)] = tmp_float;
                                                                break;

                                                            default:
                                                                //row[r.GetCellIndex(c)] = c.Node.InnerText;
                                                                foreach(Paragraph p in c.Content) {
                                                                    foreach(SimpleText text in p.TextContent) {
                                                                        row[r.GetCellIndex(c)] = text.Text;
                                                                    }
                                                                }
                                                                break;
                                                        }
                                                    }
                                                    else {
                                                        //row[r.GetCellIndex(c)] = c.Node.InnerText;

                                                        foreach(Paragraph p in c.Content) {
                                                            foreach(SimpleText text in p.TextContent) {
                                                                row[r.GetCellIndex(c)] = text.Text;
                                                            }
                                                        }
                                                    }
                                                }
                                                catch(Exception) {
                                                    try {
                                                        //row[r.GetCellIndex(c)] = (c.Node.InnerText != null ? c.Node.InnerText : "");
                                                    }
                                                    catch(Exception) {
                                                        row[r.GetCellIndex(c)] = DBNull.Value;
                                                    }
                                                }
                                            }

                                            if(withEventThrowing) {
                                                throwValue += addValue;

                                                if(throwValue <= percentMax) {
                                                    this.PercentState(this, new ImportStateEventArgs(throwValue));
                                                }
                                            }
                                            else {
                                                this._allObjectsInFile++;
                                            }
                                        }
                                    }

                                    if(row[0] != DBNull.Value) {
                                        data.Tables[0].Rows.Add(row);
                                    }

                                    if(withEventThrowing) {
                                        throwValue += addValue;

                                        if(throwValue <= percentMax) {
                                            this.PercentState(this, new ImportStateEventArgs(throwValue));
                                        }
                                    }
                                    else {
                                        this._allObjectsInFile++;
                                    }
                                }
                                catch(Exception) {
                                }
                            }

                            count++;
                        }

                        if(withEventThrowing) {
                            // send a last event with a value of 100 percent
                            this.PercentState(this, new ImportStateEventArgs(percentMax));
                        }

                        // break after the first table (for this time)
                        break;
                    }
                }
            }
            catch(Exception ex) {
                throw new Exception(
                    "Error on loading data from OpenDocument spreadsheet!",
                    ex
                );
            }

            return data;
        }
예제 #6
0
        /// <summary>
        /// Start the import
        /// </summary>
        /// <param name="allocation">The column allocation.</param>
        /// <returns>Returns true if the import was successfull.</returns>
        public bool Import(List<ColumnAllocation> allocation)
        {
            if(!this._doc.IsLoadedFile) {
                return false;
            }
            else {
                if(this._doc.TableCount > 0) {
                    int percentMax = 50;
                    double addValue = addValue = Convert.ToDouble(
                        Convert.ToDouble(percentMax) / Convert.ToDouble(this._allObjectsInFile)
                    );
                    double throwValue = percentMax;
                    int nextMovieNumber = this._dh.GetNextMovieNumber();

                    DataSet data = this._ConvertSpreadsheetToDataset(true);

                    DataSet content = this._db.ExecuteQuery("SELECT * FROM tbl_movies");

                    ImportHelper ih = new ImportHelper();

                    if(data.Tables[0].Rows.Count > 0) {
                        DataTableReader reader = data.CreateDataReader();
                        DataRow row;
                        string tmp_str = "";
                        bool tmp_bool = false;
                        int tmp_int = 0;
                        string newPkid = "";
                        StringBuilder str = new StringBuilder();
                        DataSet eData;

                        try {
                            while(reader.Read()) {
                                row = content.Tables[0].NewRow();

                                // data
                                newPkid = Helper.NewGuid;
                                row["pkid"] = newPkid;

                                // number
                                if(ih.CheckForAllocatedColumn(allocation, "number")) {
                                    if(!int.TryParse(reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "number")
                                        )
                                    ).ToString(), out tmp_int)) {
                                        tmp_int = 0;
                                    }

                                    row["number"] = tmp_int;
                                }
                                else {
                                    row["number"] = nextMovieNumber;
                                }

                                // name
                                if(ih.CheckForAllocatedColumn(allocation, "name")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "name")
                                        )
                                    ).ToString();

                                    row["name"] = tmp_str + "";
                                }
                                else {
                                    row["name"] = "";
                                }

                                // note
                                if(ih.CheckForAllocatedColumn(allocation, "note")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "note")
                                        )
                                    ).ToString();

                                    row["note"] = tmp_str + "";
                                }
                                else {
                                    row["note"] = "";
                                }

                                // has_cover
                                if(ih.CheckForAllocatedColumn(allocation, "has_cover")) {
                                    //if(!bool.TryParse(reader.GetValue(
                                    //    reader.GetOrdinal(
                                    //        ih.GetAllocatedColumnName(allocation, "has_cover")
                                    //    )
                                    //).ToString(), out tmp_bool)) {
                                    //    tmp_bool = false;
                                    //}

                                    //row["has_cover"] = tmp_bool;

                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "has_cover")
                                        )
                                    ).ToString();

                                    if(tmp_str.ToLower().Contains("x")
                                    || tmp_str.ToLower().IsExpressionTrue()) {
                                        row["has_cover"] = true;
                                    }
                                    else {
                                        row["has_cover"] = false;
                                    }
                                }
                                else {
                                    row["has_cover"] = false;
                                }

                                // is_original
                                if(ih.CheckForAllocatedColumn(allocation, "is_original")) {
                                    //if(!bool.TryParse(reader.GetValue(
                                    //    reader.GetOrdinal(
                                    //        ih.GetAllocatedColumnName(allocation, "is_original")
                                    //    )
                                    //).ToString(), out tmp_bool)) {
                                    //    tmp_bool = false;
                                    //}

                                    //row["is_original"] = tmp_bool;

                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "is_original")
                                        )
                                    ).ToString();

                                    if(tmp_str.ToLower().Contains("x")
                                    || tmp_str.ToLower().IsExpressionTrue()) {
                                        row["is_original"] = true;
                                    }
                                    else {
                                        row["is_original"] = false;
                                    }
                                }
                                else {
                                    row["is_original"] = false;
                                }

                                // is_conferred
                                if(ih.CheckForAllocatedColumn(allocation, "is_conferred")) {
                                    //if(!bool.TryParse(reader.GetValue(
                                    //    reader.GetOrdinal(
                                    //        ih.GetAllocatedColumnName(allocation, "is_conferred")
                                    //    )
                                    //).ToString(), out tmp_bool)) {
                                    //    tmp_bool = false;
                                    //}

                                    //row["is_conferred"] = tmp_bool;

                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "is_conferred")
                                        )
                                    ).ToString();

                                    if(tmp_str.ToLower().Contains("x")
                                    || tmp_str.ToLower().IsExpressionTrue()) {
                                        row["is_conferred"] = true;
                                    }
                                    else {
                                        row["is_conferred"] = false;
                                    }
                                }
                                else {
                                    row["is_conferred"] = false;
                                }

                                // codec
                                Codec tmpCodec = Codec.Unknown;

                                if(ih.CheckForAllocatedColumn(allocation, "codec")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "codec")
                                        )
                                    ).ToString();

                                    if(tmp_str.ToLower().Contains("divx")) {
                                        tmpCodec = Codec.Divx;
                                        row["codec"] = (int)Codec.Divx;
                                    }
                                    else if(tmp_str.ToLower().Contains("dvd")) {
                                        tmpCodec = Codec.DVD;
                                        row["codec"] = (int)Codec.DVD;
                                    }
                                    else if(tmp_str.ToLower().Contains("mpeg")) {
                                        tmpCodec = Codec.MPEG;
                                        row["codec"] = (int)Codec.MPEG;
                                    }
                                    else if(tmp_str.ToLower().Contains("mvcd")) {
                                        tmpCodec = Codec.MVCD;
                                        row["codec"] = (int)Codec.MVCD;
                                    }
                                    else if(tmp_str.ToLower().Contains("svcd")) {
                                        tmpCodec = Codec.SVCD;
                                        row["codec"] = (int)Codec.SVCD;
                                    }
                                    else if(tmp_str.ToLower().Contains("vcd")) {
                                        tmpCodec = Codec.VCD;
                                        row["codec"] = (int)Codec.VCD;
                                    }
                                    else if(tmp_str.ToLower().Contains("wmv")) {
                                        tmpCodec = Codec.WMV;
                                        row["codec"] = (int)Codec.WMV;
                                    }
                                    else if(tmp_str.ToLower().Contains("xvid")) {
                                        tmpCodec = Codec.Xvid;
                                        row["codec"] = (int)Codec.Xvid;
                                    }
                                    else if(tmp_str.ToLower().Contains("vhs")) {
                                        tmpCodec = Codec.VHS;
                                        row["codec"] = (int)Codec.VHS;
                                    }
                                }
                                else {
                                    row["codec"] = 6;
                                }

                                // conferred_to
                                if(ih.CheckForAllocatedColumn(allocation, "conferred_to")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "conferred_to")
                                        )
                                    ).ToString();

                                    row["conferred_to"] = tmp_str + "";
                                }
                                else {
                                    row["conferred_to"] = "";
                                }

                                // disc_amount
                                if(ih.CheckForAllocatedColumn(allocation, "disc_amount")) {
                                    if(!int.TryParse(reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "disc_amount")
                                        )
                                    ).ToString(), out tmp_int)) {
                                        tmp_int = 0;
                                    }

                                    row["disc_amount"] = tmp_int;
                                }
                                else {
                                    row["disc_amount"] = 0;
                                }

                                // year
                                if(ih.CheckForAllocatedColumn(allocation, "year")) {
                                    if(!int.TryParse(reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "year")
                                        )
                                    ).ToString(), out tmp_int)) {
                                        tmp_int = 0;
                                    }

                                    row["year"] = tmp_int;
                                }
                                else {
                                    row["year"] = -1;
                                }

                                // country
                                //????????? (string, but only the country-code)
                                row["country"] = "";

                                // quality
                                //????????? (int)
                                switch(tmpCodec) {
                                    case Codec.DVD:
                                        row["quality"] = 8;
                                        break;

                                    case Codec.VHS:
                                        row["quality"] = 3;
                                        break;

                                    default:
                                        row["quality"] = 5;
                                        break;
                                }

                                // GENRE
                                if(ih.CheckForAllocatedColumn(allocation, "__GENRE")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "__GENRE")
                                        )
                                    ).ToString();

                                    if(tmp_str.Length > 0) {
                                        string[] genres = tmp_str.Split(new char[] { ',' });

                                        List<Genre> lGenre = new List<Genre>();
                                        List<Genre> lNewGenre = new List<Genre>();

                                        foreach(string genre in genres) {
                                            Genre tmp = this._dh.GetGenreByName(genre);

                                            if(tmp != null) {
                                                lGenre.Add(tmp);
                                            }
                                            else {
                                                Genre g = new Genre();

                                                g.ID = Helper.NewGuid;
                                                g.Name = genre;

                                                lGenre.Add(g);
                                                lNewGenre.Add(g);
                                            }
                                        }

                                        // save genres
                                        this._dh.SaveNewGenreList(lNewGenre);

                                        // save genre link
                                        str.Remove(0, str.Length);
                                        str.Append("DELETE ");
                                        str.Append(" FROM tbl_movies_to_genres");
                                        str.Append(" WHERE movie_pkid = '" + newPkid + "'");

                                        this._db.ExecuteNonQuery(str.ToString());

                                        str.Remove(0, str.Length);
                                        str.Append("SELECT * ");
                                        str.Append(" FROM tbl_movies_to_genres");

                                        try {
                                            eData = null;
                                            eData = this._db.ExecuteQuery(str.ToString());
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on loading genres from table!", ex);
                                        }

                                        foreach(Genre g in lGenre) {
                                            DataRow hrow = eData.Tables[0].NewRow();

                                            hrow["pkid"] = Helper.NewGuid;
                                            hrow["genre_pkid"] = g.ID;
                                            hrow["movie_pkid"] = newPkid;

                                            eData.Tables[0].Rows.Add(hrow);
                                        }

                                        try {
                                            this._db.ExecuteUpdate(eData, "tbl_movies_to_genres");
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on updating genres to table!", ex);
                                        }
                                    }
                                }

                                // ACTOR
                                if(ih.CheckForAllocatedColumn(allocation, "__ACTOR")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "__ACTOR")
                                        )
                                    ).ToString();

                                    if(tmp_str.Length > 0) {
                                        string[] actors = tmp_str.Split(new char[] { ',' });

                                        List<Person> lActors = new List<Person>();
                                        List<Person> lNewActors = new List<Person>();

                                        foreach(string actor in actors) {
                                            PersonName name = Tools.SplitNameByLastSpace(actor);

                                            if(name != null) {
                                                Person person = this._dh.GetPersonByName(
                                                    name.Firstname,
                                                    name.Lastname,
                                                    MovieObjectType.All
                                                );

                                                if(person != null) {
                                                    person.IsActor = true;

                                                    this._dh.SavePerson(
                                                        person,
                                                        SaveMethod.SaveChanges
                                                    );

                                                    lActors.Add(person);
                                                }
                                                else {
                                                    Person p = new Person();

                                                    p.ID = Helper.NewGuid;
                                                    p.Firstname = name.Firstname;
                                                    p.Lastname = name.Lastname;
                                                    p.IsActor = true;

                                                    this._dh.SavePerson(
                                                        p,
                                                        SaveMethod.CreateNewWithoutID
                                                    );

                                                    lActors.Add(p);
                                                    lNewActors.Add(p);
                                                }
                                            }
                                        }

                                        // save new persons
                                        //this._dh.SaveNewPersonList(lNewActors);

                                        // save person link
                                        //str.Remove(0, str.Length);
                                        //str.Append("DELETE ");
                                        //str.Append(" FROM tbl_movies_to_persons");
                                        //str.Append(" WHERE movie_pkid = '" + newPkid + "'");

                                        //this._db.ExecuteNonQuery(str.ToString());

                                        str.Remove(0, str.Length);
                                        str.Append("SELECT * ");
                                        str.Append(" FROM tbl_movies_to_persons");

                                        try {
                                            eData = null;
                                            eData = this._db.ExecuteQuery(str.ToString());
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on loading persons from table!", ex);
                                        }

                                        foreach(Person p in lActors) {
                                            DataRow hrow = eData.Tables[0].NewRow();

                                            hrow["pkid"] = Helper.NewGuid;
                                            hrow["person_pkid"] = p.ID;
                                            hrow["movie_pkid"] = newPkid;
                                            hrow["as_actor"] = true;

                                            eData.Tables[0].Rows.Add(hrow);
                                        }

                                        try {
                                            this._db.ExecuteUpdate(eData, "tbl_movies_to_persons");
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on updating persons to table!", ex);
                                        }
                                    }
                                }

                                // DIRECTOR
                                if(ih.CheckForAllocatedColumn(allocation, "__DIRECTOR")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "__DIRECTOR")
                                        )
                                    ).ToString();

                                    if(tmp_str.Length > 0) {
                                        string[] directors = tmp_str.Split(new char[] { ',' });

                                        List<Person> lDirectors = new List<Person>();
                                        List<Person> lNewDirectors = new List<Person>();

                                        foreach(string director in directors) {
                                            PersonName name = Tools.SplitNameByLastSpace(director);

                                            if(name != null) {
                                                Person person = this._dh.GetPersonByName(
                                                    name.Firstname,
                                                    name.Lastname,
                                                    MovieObjectType.All
                                                );

                                                if(person != null) {
                                                    person.IsDirector = true;

                                                    this._dh.SavePerson(
                                                        person,
                                                        SaveMethod.SaveChanges
                                                    );

                                                    lDirectors.Add(person);
                                                }
                                                else {
                                                    Person p = new Person();

                                                    p.ID = Helper.NewGuid;
                                                    p.Firstname = name.Firstname;
                                                    p.Lastname = name.Lastname;
                                                    p.IsDirector = true;

                                                    this._dh.SavePerson(
                                                        p,
                                                        SaveMethod.CreateNewWithoutID
                                                    );

                                                    lDirectors.Add(p);
                                                    lNewDirectors.Add(p);
                                                }
                                            }
                                        }

                                        // save new persons
                                        //this._dh.SaveNewPersonList(lNewDirectors);

                                        // save person link
                                        //str.Remove(0, str.Length);
                                        //str.Append("DELETE ");
                                        //str.Append(" FROM tbl_movies_to_persons");
                                        //str.Append(" WHERE movie_pkid = '" + newPkid + "'");

                                        //this._db.ExecuteNonQuery(str.ToString());

                                        str.Remove(0, str.Length);
                                        str.Append("SELECT * ");
                                        str.Append(" FROM tbl_movies_to_persons");

                                        try {
                                            eData = null;
                                            eData = this._db.ExecuteQuery(str.ToString());
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on loading persons from table!", ex);
                                        }

                                        foreach(Person p in lDirectors) {
                                            DataRow hrow = eData.Tables[0].NewRow();

                                            hrow["pkid"] = Helper.NewGuid;
                                            hrow["person_pkid"] = p.ID;
                                            hrow["movie_pkid"] = newPkid;
                                            hrow["as_director"] = true;

                                            eData.Tables[0].Rows.Add(hrow);
                                        }

                                        try {
                                            this._db.ExecuteUpdate(eData, "tbl_movies_to_persons");
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on updating persons to table!", ex);
                                        }
                                    }
                                }

                                // PRODUCER
                                if(ih.CheckForAllocatedColumn(allocation, "__PRODUCER")) {
                                    tmp_str = reader.GetValue(
                                        reader.GetOrdinal(
                                            ih.GetAllocatedColumnName(allocation, "__PRODUCER")
                                        )
                                    ).ToString();

                                    if(tmp_str.Length > 0) {
                                        string[] producers = tmp_str.Split(new char[] { ',' });

                                        List<Person> lProducers = new List<Person>();
                                        List<Person> lNewProducers = new List<Person>();

                                        foreach(string producer in producers) {
                                            PersonName name = Tools.SplitNameByLastSpace(producer);

                                            if(name != null) {
                                                Person person = this._dh.GetPersonByName(
                                                    name.Firstname,
                                                    name.Lastname,
                                                    MovieObjectType.All
                                                );

                                                if(person != null) {
                                                    person.IsProducer = true;

                                                    this._dh.SavePerson(
                                                        person,
                                                        SaveMethod.SaveChanges
                                                    );

                                                    lProducers.Add(person);
                                                }
                                                else {
                                                    Person p = new Person();

                                                    p.ID = Helper.NewGuid;
                                                    p.Firstname = name.Firstname;
                                                    p.Lastname = name.Lastname;
                                                    p.IsProducer = true;

                                                    this._dh.SavePerson(
                                                        p,
                                                        SaveMethod.CreateNewWithoutID
                                                    );

                                                    lProducers.Add(p);
                                                    lNewProducers.Add(p);
                                                }
                                            }
                                        }

                                        // save new persons
                                        //this._dh.SaveNewPersonList(lNewProducers);

                                        // save person link
                                        //str.Remove(0, str.Length);
                                        //str.Append("DELETE ");
                                        //str.Append(" FROM tbl_movies_to_persons");
                                        //str.Append(" WHERE movie_pkid = '" + newPkid + "'");

                                        //this._db.ExecuteNonQuery(str.ToString());

                                        str.Remove(0, str.Length);
                                        str.Append("SELECT * ");
                                        str.Append(" FROM tbl_movies_to_persons");

                                        try {
                                            eData = null;
                                            eData = this._db.ExecuteQuery(str.ToString());
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on loading persons from table!", ex);
                                        }

                                        foreach(Person p in lProducers) {
                                            DataRow hrow = eData.Tables[0].NewRow();

                                            hrow["pkid"] = Helper.NewGuid;
                                            hrow["person_pkid"] = p.ID;
                                            hrow["movie_pkid"] = newPkid;
                                            hrow["as_producer"] = true;

                                            eData.Tables[0].Rows.Add(hrow);
                                        }

                                        try {
                                            this._db.ExecuteUpdate(eData, "tbl_movies_to_persons");
                                        }
                                        catch(Exception ex) {
                                            throw new Exception("Error on updating persons to table!", ex);
                                        }
                                    }
                                }

                                throwValue += addValue;

                                if(throwValue <= (percentMax * 2)) {
                                    this.PercentState(this, new ImportStateEventArgs(throwValue));
                                }

                                content.Tables[0].Rows.Add(row);

                                nextMovieNumber++;
                            }

                            // save
                            try {
                                this._db.ExecuteUpdate(content, "tbl_movies");
                            }
                            catch(Exception ex) {
                                throw new Exception("Error on updating movie to table (during import)!", ex);
                            }
                        }
                        catch(Exception ex) {
                            throw new Exception("Error on adding rows to the movies table (during import)!", ex);
                        }
                    }

                    // send a last event with a value of 100 percent
                    this.PercentState(this, new ImportStateEventArgs(percentMax + percentMax));
                }
            }

            return true;
        }
예제 #7
0
		/// <summary>
		/// Create a new ListItem
		/// </summary>
		/// <param name="list">The List object to which this ListItem belongs.</param>
		public ListItem(List list)
		{
			this.Document				= list.Document;
			this.List					= list;
			this.InitStandards();
		}
예제 #8
0
 public void SimpleTableWithList()
 {
     //Create a new text document
     var document = new TextDocument();
     document.New();
     //Create a table for a text document using the TableBuilder
     var table = TableBuilder.CreateTextDocumentTable(
         document,
         "table1",
         "table1",
         3,
         3,
         16.99,
         false,
         false);
     //Create a bullet list
     var list = new AODL.Document.Content.Text.List(document, "L1", ListStyles.Bullet, "L1P1");
     //Create a list item
     var lit = new ListItem(list);
     //Create a standard paragraph
     var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
     //Add some simple text
     paragraph.TextContent.Add(new SimpleText(document, "List item text"));
     //Add paragraph to the list item
     lit.Content.Add(paragraph);
     //Add item to the list
     list.Content.Add(lit);
     //Insert paragraph into the first cell
     table.RowCollection[0].CellCollection[0].Content.Add(list);
     //Add table to the document
     document.Content.Add(table);
     //Save the document
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "simpleTableWithList.odt");
 }
예제 #9
0
        protected void Save_Click(object sender, EventArgs e)
        {
            this.Validate();
            if (this.IsValid)
            {
                // Проверяем, является ли продукт основной версией
                ProductProvider productProvider = new ProductProvider();
                if (productProvider.IsMainVersion(this.ProductID))
                {
                    LabelErrorMessage.Text = "[ ! ] Содержащий данную спецификацию продукт является основной версией. Сохранение отменено.";
                    return;
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                List<Dictionary<string, string>> rows = js.Deserialize<List<Dictionary<string, string>>>(hiddenStoreData.Value.ToString());
                EditConfigurationProvider provider = new EditConfigurationProvider();
                List<GridColumn> gridColumns = provider.GetGridColumns();

                // Сохраняем данные, полученные от пользователя в списке конфигураций
                List<Aspect.Domain.Configuration> result = new List<Aspect.Domain.Configuration>();
                #region convert Request to list of Configuration
                foreach (Dictionary<string, string> row in rows)
                {
                    Guid productID = new Guid(row["ID"]);
                    Aspect.Domain.Configuration conf = new Aspect.Domain.Configuration();
                    conf.ID = new Guid(row["ConfID"]);
                    conf.ProductID = productID;
                    conf.ProductOwnerID = this.ProductID;
                    conf.UserID = this.User.ID;

                    foreach (GridColumn column in gridColumns)
                    {
                        if (column is EditableGridColumn)
                        {
                            System.Reflection.PropertyInfo prop = typeof(Aspect.Domain.Configuration).GetProperty(column.DataItem);
                            if (prop.PropertyType == typeof(decimal) || prop.PropertyType == typeof(Nullable<decimal>))
                            {
                                prop.SetValue(conf, Convert.ToDecimal(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(Nullable<int>))
                            {
                                prop.SetValue(conf, Convert.ToInt32(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(Guid) || prop.PropertyType == typeof(Nullable<Guid>))
                            {
                                prop.SetValue(conf, new Guid(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(Boolean) || prop.PropertyType == typeof(Nullable<Boolean>))
                            {
                                prop.SetValue(conf, Convert.ToBoolean(row[column.DataItem]), null);
                            }
                            else
                            {
                                prop.SetValue(conf, row[column.DataItem], null);
                            }
                        }
                    }

                    result.Add(conf);
                }
                #endregion

                using (CommonDomain domain = new CommonDomain())
                {
                    // Проверка на включение материалов
                    #region check_including_material
                    foreach (Aspect.Domain.Configuration conf in result)
                    {
                        Product prod = domain.Products.Single(p => p.ID == conf.ProductID);
                        if (prod._dictNomen.cod >= 1000000)
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены материалы в спецификации. Сохранение отменино.";
                            return;
                        }
                    }
                    #endregion

                    // Проверка на циклы
                    #region check_for_cycles
                    Guid dictNomenID = (Guid) (from p in domain.Products
                                               where p.ID == this.ProductID
                                               select p).Single()._dictNomenID;
                    foreach (Aspect.Domain.Configuration conf in result)
                    {
                        Product prod = domain.Products.Where(p => p.ID == conf.ProductID).Single();
                        if (dictNomenID == prod._dictNomenID)
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены циклические включения продуктов в спецификацию. Сохранение отменино.";
                            return;
                        }
                        if (fnCheckContains(dictNomenID, prod.ID))
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены циклические включения продуктов в спецификацию. Сохранение отменино.";
                            return;
                        }
                    }
                    #endregion
                }

                provider.SaveProductConfiguration(this.ProductID, result, this.User.ID);

                // установка признака "Основная версия"
                if (MadeBasicVersion.Checked)
                {
                    productProvider.SetMainVersion(this.User.ID, new List<Guid>{ProductID});
                }

                // устанавливаем основание изменений
                if (!String.IsNullOrEmpty(ReasonChanges.Text))
                {
                    ProductProperty reasonProperty = productProvider.ProductProperties.SingleOrDefault(
                        pr => pr.PropertyID == new Guid("C266B994-9740-41F6-94DD-07EA5B5FA34A")
                        && pr.ProductID == this.ProductID);

                    if (reasonProperty == null)
                    {
                        reasonProperty = new ProductProperty()
                        {
                            ID = Guid.NewGuid(),
                            PropertyID = new Guid("C266B994-9740-41F6-94DD-07EA5B5FA34A"),
                            ProductID = this.ProductID,
                            Value = ReasonChanges.Text
                        };
                        productProvider.ProductProperties.InsertOnSubmit(reasonProperty);
                    }
                    else
                    {
                        reasonProperty.Value = ReasonChanges.Text;
                    }
                    productProvider.SubmitChanges();
                }

                // Очищаем сообщение об ошибке и обновляем данные о спецификации
                LabelErrorMessage.Text = "";
                this.BindGridColumns2();
                this.BindData(new Dictionary<Guid, Guid>());
            }
        }
예제 #10
0
		/// <summary>
		/// Create a new List which is used to represent a inner list.
		/// </summary>
		/// <param name="document">The IDocument</param>
		/// <param name="outerlist">The List to which this List belongs.</param>
		public List(IDocument document, List outerlist)
		{
			this.Document						= document;
			this.ParagraphStyle					= outerlist.ParagraphStyle;			
			this.InitStandards();
			this._type							= outerlist.ListType;
			//Create an inner list node, don't need a style
			//use the parents list style
			this.NewXmlNode();
		}
예제 #11
0
        /// <summary>
        /// Gets the list as HTML.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns></returns>
        public string GetListAsHtml(List list)
        {
            string html					= "<";

            try
            {
                if(list != null)
                {
                    if(list.ListType == ListStyles.Number)
                        html		+= "ol>\n";
                    else
                        html		+= "ul>\n";

                    if(list.Content != null)
                    {
                        foreach(IContent iContent in list.Content)
                            html		+= this.GetIContentCollectionAsHtml(list.Content);
                    }
                }
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to build a HTML string from a List object.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.OriginalException	= ex;

                throw exception;
            }

            if(html.StartsWith("<ol"))
                html				+= "</ol>\n";
            else if(html.StartsWith("<ul"))
                html				+= "</ul>\n";
            else
                html				= "";

            return html;
        }
예제 #12
0
        /*
         * Метод перелистывания страниц в гриде
         */
        protected void Store1_RefreshData(object sender, Ext.Net.StoreRefreshDataEventArgs e)
        {
            DataSet data = null;
            List<GridColumn> columns = new List<GridColumn>();

            using (ContentDomain provider = Common.GetContentDomain(ClassifiacationTypeView))
            {
                Domain.OrderExpression OrderExpression = new OrderExpression();
                if (e.Sort.Length > 0)
                {
                    string expr = e.Sort.Split('|')[0];
                    string tp = e.Sort.Split('|')[1];
                    OrderExpression.Expression = expr;
                    OrderExpression.ColumnType = (TypeEnum)Enum.Parse(typeof(TypeEnum), tp);
                }

                if (e.Dir == Ext.Net.SortDirection.DESC)
                    OrderExpression.SortDirection = Aspect.Domain.SortDirection.desc;

                List<SearchExpression> listSearch = this.SearchConditions.ToList();
                // показывать только выбранные
                if (this.ShowSelected && !String.IsNullOrEmpty(hiddenSelectedProducts.Value.ToString()))
                {
                    SearchExpression selected = new SearchExpression();
                    selected.FieldCond = Condition.Inset;
                    selected.FieldValue = hiddenSelectedProducts.Value.ToString();
                    selected.FieldName = "ID";
                    listSearch.Add(selected);
                }
                // показывать основные версии
                if (FilterView.Value.ToString().Contains("mainVers"))
                {
                    SearchExpression mainVers = new SearchExpression();
                    mainVers.FieldID = new Guid("BBE170B0-28E4-4738-B365-1038B03F4552"); //основная версия
                    mainVers.FieldValue = "1";
                    listSearch.Add(mainVers);
                }
                // показывать приказные версии
                if (FilterView.Value.ToString().Contains("prikazVers"))
                {
                    SearchExpression mainVers = new SearchExpression();
                    mainVers.FieldCond = Condition.Beable;
                    mainVers.FieldValue = "9A38E338-DD60-4636-BFE3-6A98BAF8AE87"; // номер приказала
                    listSearch.Add(mainVers);
                }

                // получить страницу из списка продуктов, попадающих под все заданные условия
                data = provider.GetList(RequestClassificationTreeID, this.User.ID, OrderExpression, listSearch, new PagingInfo(e.Start, e.Limit));
                columns = provider.GetGridColumns(this.User.ID, RequestClassificationTreeID, FieldPlaceHolder.Grid);
            }
            if (data != null && data.Tables.Count > 0)
            {
                e.Total = data.Tables[1].Rows[0].Field<int>(0);
                List<object> dataSource = new List<object>();

                foreach (DataRow row in data.Tables[2].Rows)
                {
                    List<object> dataRow = new List<object>();
                    foreach (GridColumn column in columns)
                    {
                        if (column.GridColumnType == TypeEnum.Boolean)
                        {
                            dataRow.Add(row[column.DataItem].ToString() == "1");
                        }
                        else if (column.GridColumnType == TypeEnum.Datetime)
                        {
                            try
                            {
                                dataRow.Add(row.Field<DateTime>(column.DataItem).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                            }
                            catch
                            {
                                dataRow.Add(row[column.DataItem].ToString());
                            }
                        }
                        else
                        {
                            dataRow.Add(row[column.DataItem].ToString());
                        }
                    }
                    // adding another field
                    dataRow.Add(row["ID"].ToString());
                    dataRow.Add(ClassifiacationTypeView == ClassifiacationTypeView.Dictionary ? this.RequestClassificationTreeID : Guid.Empty);
                    dataSource.Add(dataRow.ToArray());
                }
                this.Store1.DataSource = dataSource;
                this.Store1.DataBind();
            }
        }
예제 #13
0
        protected void PrintSelected_Click(object sender, EventArgs e)
        {
            string fileName = string.Format("products-{0:yyyy-MM-dd_hh-mm-ss}.odt", DateTime.Now);

            TextDocument document = new TextDocument();
            AODL.Document.Content.Tables.Table table;
            document.New();

            using (ContentDomain provider = Common.GetContentDomain(ClassifiacationTypeView))
            {
                //TreeNode node = ClassificationView.SelectedNode;
                List<GridColumn> columns = provider.GetGridColumns(this.User.ID, this.RequestClassificationTreeID, FieldPlaceHolder.Grid);
                DataSet data = provider.GetList(this.RequestClassificationTreeID, this.User.ID, this.OrderExpression,
                    this.SearchConditions, new PagingInfo(false));

                // составляем список выделенных продуктов
                List<Guid> selectedRows;
                if (hiddenSelectedProducts.Value.ToString() != "")
                    selectedRows = hiddenSelectedProducts.Value.ToString().Split(',').Select(s => new Guid(s)).ToList();
                else
                    selectedRows = new List<Guid>();

                //Create a table for a text document using the TableBuilder
                table = TableBuilder.CreateTextDocumentTable(
                    document,
                    "table1",
                    "table1",
                    selectedRows.Count + 1,
                    columns.Count,
                    16.99,
                    false,
                    true);

                //Fill the cells
                int columnIndex = 0, rowIndex = 0;
                foreach (GridColumn column in columns)
                {
                    Cell cell = table.RowCollection[0].CellCollection[columnIndex];
                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    paragraph.TextContent.Add(new SimpleText(document, column.Name));
                    cell.Content.Add(paragraph);
                    columnIndex++;
                }
                rowIndex++;

                foreach (DataRow row in data.Tables[0].Rows)
                {
                    Guid rodId = row.Field<Guid>("ID");
                    if (!selectedRows.Contains(rodId)) continue;

                    columnIndex = 0;
                    foreach (GridColumn column in columns)
                    {
                        if (!row.IsNull(column.DataItem))
                        {
                            try
                            {
                                Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                string value = row.Field<string>(column.DataItem);
                                paragraph.TextContent.Add(new SimpleText(document, value));
                                cell.Content.Add(paragraph);
                            }
                            catch (System.Exception)
                            {
                                try
                                {
                                    Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                    int value = row.Field<int>(column.DataItem);
                                    paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                    cell.Content.Add(paragraph);
                                }
                                catch (System.Exception)
                                {
                                    try
                                    {
                                        Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                        Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                        decimal value = row.Field<decimal>(column.DataItem);
                                        paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                        cell.Content.Add(paragraph);
                                    }
                                    catch (System.Exception)
                                    {

                                    }
                                }
                            }
                        }
                        columnIndex++;
                    }
                    rowIndex++;
                }

            }

            //Add table to the document
            document.Content.Add(table);
            //Save the document
            string tmpCurrentDitectory = Environment.CurrentDirectory;
            Environment.CurrentDirectory = Server.MapPath("~/tmp").ToString();
            String fs_guid = Server.MapPath(String.Format("~/tmp/{0}.odt", Guid.NewGuid().ToString()));
            document.SaveTo(fs_guid);
            document.Dispose();
            Environment.CurrentDirectory = tmpCurrentDitectory;

            Response.Clear();
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/octet-stream";

            // Copy file to Response stream
            FileStream fs = new FileStream(fs_guid, FileMode.Open);
            Response.AddHeader("Content-Length", fs.Length.ToString());

            int bufferSize = 4096;
            byte[] buffer = new byte[bufferSize];
            while (true)
            {
                int read = fs.Read(buffer, 0, buffer.Length);
                if (read <= 0)
                {
                    break;
                }
                Response.OutputStream.Write(buffer, 0, read);
            }

            fs.Close(); //закрываем writer
            File.Delete(fs_guid);
            Response.End(); //заканчиваем ответ сервера, иначе после этого вставится весь контент страницы
            return;
        }
예제 #14
0
        /*public void BindClassificationView(ITreeProvider provider, Guid parentID, TreeNode parentNode, Guid selectedID)
        {
            List<ITreeNode> list = new List<ITreeNode>();
            if (!parentID.Equals(Guid.Empty) && parentNode == null)
            {
                ITreeNode entity = provider.GetTreeNode(parentID);
                if (entity == null) return;
                list.Add(entity);
            }
            else
            {
                list = provider.GetList(parentID, User.ID, Roles);
                //List<ITreeNode> list = provider.GetList(parentID);
            }
            foreach (ITreeNode item in list)
            {
                Basic.ColoredTreeNode node;
                switch (item.Section)
                {
                    case TreeNodeSection.Custom:
                        node = new Basic.ColoredTreeNode(item.Name, String.Format("cust-{0}", item.ID));
                        node.Color =
                    case TreeNodeSection.Default:
                        new Basic.ColoredTreeNode(item.Name, item.ID.ToString());
                }
                = new Basic.ColoredTreeNode(item.Name, item.ID.ToString());
                node.Color = item.Color;

                if (item.ID == selectedID) node.Select();
                node.NavigateUrl = string.Format("Grid.aspx?cid={0}&pid={1}", node.Value, this.ClassificationTopNodeID);
                if (parentNode != null) parentNode.ChildNodes.Add(node);
                else ClassificationView.Nodes.Add(node);
                this.BindClassificationView(provider, item.ID, node, selectedID);
            }
        }*/
        public void BindClassView(ITreeProvider provider, Guid parentID, Ext.Net.TreeNode parentNode, Guid selectedID)
        {
            List<ITreeNode> list = new List<ITreeNode>();
            if (!parentID.Equals(Guid.Empty) && parentNode == null)
            {
                ITreeNode entity = provider.GetTreeNode(parentID);
                if (entity == null) return;
                list.Add(entity);
            }
            else
            {
                list = provider.GetList(parentID, User.ID, Roles);
                //List<ITreeNode> list = provider.GetList(parentID);
            }
            foreach (ITreeNode item in list)
            {
                Ext.Net.TreeNode treeNode;

                if (item.ID.Equals(new Guid("00497ABC-7ADB-11E0-AD88-63F04724019B")))
                {
                    // hack for "Wares"
                    treeNode = new Ext.Net.TreeNode(String.Format("ware-{0}", item.ID), item.Name, Ext.Net.Icon.Folder);
                    treeNode.Cls = "TreeNode-Wares";
                    treeNode.Href = String.Format("/Technology/ListWares.aspx");
                }
                else
                {
                    switch (item.Section)
                    {
                        case TreeNodeSection.Custom:
                            treeNode = new Ext.Net.TreeNode(String.Format("cust-{0}", item.ID), item.Name, Ext.Net.Icon.Folder);
                            treeNode.Cls = "TreeNode-Custom";
                            break;
                        case TreeNodeSection.Dictionary:
                            treeNode = new Ext.Net.TreeNode(String.Format("dict-{0}", item.ID), item.Name, Ext.Net.Icon.Folder);
                            treeNode.Cls = "TreeNode-Dictionary";
                            break;
                        default:
                            treeNode = new Ext.Net.TreeNode(String.Format("dflt-{0}", item.ID), item.Name, Ext.Net.Icon.Folder);
                            treeNode.Cls = "TreeNode-Default";
                            break;
                    }
                    treeNode.Href = String.Format("/Grid.aspx?cid={0}", item.ID);
                }
                if (parentNode != null) parentNode.Nodes.Add(treeNode);
                else (ClassView.Root[0] as Ext.Net.TreeNode).Nodes.Add(treeNode);

                if (item.ID == this.RequestClassificationTreeID)
                {
                    this.selectedNodeID = this.RequestClassificationTreeID;
                    this.selectedNodeText = item.Name;
                    ClassView.SelectNode(treeNode.NodeID);
                    Ext.Net.TreeNodeBase tmpParent = treeNode.ParentNode;
                    while (tmpParent != null)
                    {
                        tmpParent.Expanded = true;
                        tmpParent = tmpParent.ParentNode;
                    }

                    //ClassView.SelectNode(treeNode.NodeID);
                    //ClassView.ExpandChildNodes(treeNode.NodeID);
                }
                this.BindClassView(provider, item.ID, treeNode, selectedID);
            }
        }
		/// <summary>
		/// Gets the list as HTML.
		/// </summary>
		/// <param name="list">The list.</param>
		/// <returns></returns>
		public string GetListAsHtml(List list)
		{
			string html					= "<";

			try
			{
				if (list != null)
				{
					if (list.ListType == ListStyles.Number)
						html		+= "ol>\n";
					else
						html		+= "ul>\n";
					
					if (list.Content != null)
					{
						foreach(IContent iContent in list.Content)
							html		+= this.GetIContentCollectionAsHtml(list.Content);
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from a List object.", ex);
			}

			if (html.StartsWith("<ol"))
				html				+= "</ol>\n";
			else if (html.StartsWith("<ul"))
				html				+= "</ul>\n";
			else
				html				= "";

			return html;
		}
예제 #16
0
        protected void PrintSelected_Click(object sender, EventArgs e)
        {
            string fileName = string.Format("configurations-{0:yyyy-MM-dd_hh-mm-ss}.odt", DateTime.Now);

            Response.Clear();
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/octet-stream";

            TextDocument document = new TextDocument();
            AODL.Document.Content.Tables.Table table;
            document.New();

            using (EditConfigurationProvider provider = new EditConfigurationProvider())
            {
                List<GridColumn> columns = provider.GetGridColumns();
                DataTable data = provider.GetList(ProductID).Tables[0];

                List<Guid> selectedRows;
                if (SelectedProductsHidden.Value != "")
                    selectedRows = SelectedProductsHidden.Value.Split(',').Select(s => new Guid(s)).ToList();
                else
                    selectedRows = new List<Guid>();

                //Create a table for a text document using the TableBuilder
                table = TableBuilder.CreateTextDocumentTable(
                    document,
                    "table1",
                    "table1",
                    selectedRows.Count + 1,
                    columns.Count,
                    16.99,
                    false,
                    true);

                //Fill the cells
                int columnIndex = 0, rowIndex = 0;
                foreach (GridColumn column in columns)
                {
                    Cell cell = table.RowCollection[0].CellCollection[columnIndex];
                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    paragraph.TextContent.Add(new SimpleText(document, column.Name));
                    cell.Content.Add(paragraph);
                    columnIndex++;
                }
                rowIndex++;

                foreach (DataRow row in data.Rows)
                {
                    Guid rodId = row.Field<Guid>("ConfigurationID");
                    if (!selectedRows.Contains(rodId)) continue;

                    columnIndex = 0;
                    foreach (GridColumn column in columns)
                    {
                        if (!row.IsNull(column.DataItem))
                        {
                            try
                            {
                                Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                string value = row.Field<string>(column.DataItem);
                                paragraph.TextContent.Add(new SimpleText(document, value));
                                cell.Content.Add(paragraph);
                            }
                            catch (System.Exception)
                            {
                                try
                                {
                                    Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                    int value = row.Field<int>(column.DataItem);
                                    paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                    cell.Content.Add(paragraph);
                                }
                                catch (System.Exception)
                                {
                                    try
                                    {
                                        Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                        Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                        decimal value = row.Field<decimal>(column.DataItem);
                                        paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                        cell.Content.Add(paragraph);
                                    }
                                    catch (System.Exception)
                                    {

                                    }
                                }
                            }
                        }
                        columnIndex++;
                    }
                    rowIndex++;
                }

            }

            //Merge some cells. Notice this is only available in text documents!
            // table.RowCollection[1].MergeCells(document, 1, 2, true);
            //Add table to the document
            document.Content.Add(table);
            //Save the document
            String fs_guid = Server.MapPath(String.Format("/tmp/{0}.odt", Guid.NewGuid().ToString()));
            document.SaveTo(fs_guid);
            document.Dispose();

            // Copy file to Response stream
            FileStream fs = new FileStream(fs_guid, FileMode.Open);

            int bufferSize = 4096;
            byte[] buffer = new byte[bufferSize];
            while (true)
            {
                int read = fs.Read(buffer, 0, buffer.Length);
                if (read <= 0)
                {
                    break;
                }
                Response.OutputStream.Write(buffer, 0, read);
            }

            fs.Close(); //закрываем writer
            File.Delete(fs_guid);
            Response.End(); //заканчиваем ответ сервера, иначе после этого вставится весь контент страницы
            return;
        }
예제 #17
0
		/// <summary>
		/// Creates the list.
		/// </summary>
		/// <param name="listNode">The list node.</param>
		/// <returns>The List object</returns>
		private List CreateList(XmlNode listNode)
		{
			try
			{
				#region Old code Todo: delete
				//				string stylename				= null;
				//				XmlNode	stylenode				= null;
				//				ListStyles liststyles			= ListStyles.Bullet; //as default
				//				string paragraphstylename		= null;
				//
				//				if (outerlist == null)
				//				{
				//					stylename			= this.GetStyleName(listNode.OuterXml);
				//					stylenode			= this.GetAStyleNode("text:list-style", stylename);
				//					liststyles			= this.GetListStyle(listNode);
				//				}
				//				List list					= null;
				//
				//				if (listNode.ChildNodes.Count > 0)
				//				{
				//					try
				//					{
				//						paragraphstylename	= this.GetAValueFromAnAttribute(listNode.ChildNodes.Item(0).ChildNodes.Item(0), "@style:style-name");
				//					}
				//					catch(Exception ex)
				//					{
				//						paragraphstylename	= "P1";
				//					}
				//				}
				#endregion
				//Create a new List
				List list					= new List(this._document, listNode);
				ContentCollection iColl	= new ContentCollection();
				//Revieve the ListStyle
				IStyle listStyle			= this._document.Styles.GetStyleByName(list.StyleName);

				if (listStyle != null)
					list.Style				= listStyle;

				foreach(XmlNode nodeChild in list.Node.ChildNodes)
				{
					IContent iContent		= this.CreateContent(nodeChild);

					if (iContent != null)
						AddToCollection(iContent, iColl);
					//iColl.Add(iContent);
				}

				list.Node.InnerXml			= "";

				foreach(IContent iContent in iColl)
					AddToCollection(iContent, list.Content);
				//list.Content.Add(iContent);
				
				return list;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a List.", ex);
			}
		}
예제 #18
0
        protected void BindData(Dictionary<Guid, Guid> productsConfigurations)
        {
            using (EditConfigurationProvider provider = new EditConfigurationProvider())
            {
                System.Data.DataTable dt = provider.GetList(ProductID).Tables[0];
                if (productsConfigurations.Count > 0)
                {
                    System.Data.DataTable bfDt = provider.GetAppendList(productsConfigurations).Tables[0];
                    dt.Merge(bfDt);
                }

                // FOR NEW
                using (EditConfigurationProvider prov = new EditConfigurationProvider())
                {
                    List<object> lst = new List<object>();

                    List<ColumnWidth> columnWidths = provider.ColumnWidths.Where(p => p.ClassificationTreeID == new Guid("11110000-0000-0000-0000-000011110001") && p.UserID == this.User.ID).ToList();
                    List<GridColumn> list = prov.GetGridColumns();
                    list = list.OrderBy(clm => columnWidths.Exists(w => w.ColumnID == clm.ID) ? columnWidths.Single(w => w.ColumnID == clm.ID).Index : Int32.MaxValue).ToList();

                    foreach (DataRow row in dt.Rows)
                    {
                        List<object> lst_sub = new List<object>();
                        foreach (GridColumn column in list)
                        {
                            if (column.GridColumnType == TypeEnum.Boolean)
                            {
                                if (row[column.DataItem].ToString() == "0") lst_sub.Add(false);
                                else lst_sub.Add(true);
                            }
                            else
                            {
                                lst_sub.Add(row[column.DataItem].ToString());
                            }
                        }
                        // дополнительные поля
                        lst_sub.Add(row["ID"].ToString());
                        lst_sub.Add(this.RequestClassificationTreeID.ToString());
                        lst_sub.Add(row["ConfigurationID"].ToString());
                        lst.Add(lst_sub.ToArray());
                    }

                    Store1.DataSource = lst;
                    Store1.DataBind();
                }

                //EditConfigurationGrid.DataSource = dt;
                //EditConfigurationGrid.DataBind();

                // загружаем основание изменений
                ProductProperty reasonProperty = provider.ProductProperties.SingleOrDefault(
                    pr => pr.PropertyID == new Guid("C266B994-9740-41F6-94DD-07EA5B5FA34A")
                    && pr.ProductID == this.ProductID);

                if (reasonProperty != null)
                {
                    ReasonChanges.Text = reasonProperty.Value;
                }
            }
        }