Example #1
0
 private void addNewRowToTheEnd(string worksheetName, TableDescriptionTableEntry descriptionEntry, Dictionary <string, string> record, int rowNumber)
 {
     if (descriptionEntry.Column_Number == 0)
     {
         // create a new row  at the specified row index with the first cell as the value cell
         m_reportTable.WorkSheets[worksheetName].Add(
             new ExcelRow(new List <ExcelCell>()
         {
             new ExcelCell(
                 record.Exists(descriptionEntry.Access_Column_Name) ? record[descriptionEntry.Access_Column_Name].NotEmpty() ? record[descriptionEntry.Access_Column_Name] : "" : "")
             {
                 CellFormat = descriptionEntry.Excel_Cell_Format.NotEmpty() ? descriptionEntry.Excel_Cell_Format : "",
                 Color      = descriptionEntry.Background_Color.NotEmpty() ? descriptionEntry.Background_Color : "",
                 TextColor  = descriptionEntry.Foreground_Color.NotEmpty() ? descriptionEntry.Foreground_Color : "",
                 FontSize   = descriptionEntry.Font_Size
             }
         }));
     }
     else
     {
         // create a new row with some blank cells in front of the actual value cell
         int      blankColumns = descriptionEntry.Column_Number;
         ExcelRow newRow       = new ExcelRow();
         addBlankCells(ref newRow, blankColumns);  // add some blank cells to the new row
         newRow.Add(new ExcelCell(
                        record.Exists(descriptionEntry.Access_Column_Name) ? record[descriptionEntry.Access_Column_Name].NotEmpty() ? record[descriptionEntry.Access_Column_Name] : "" : "")
         {
             CellFormat = descriptionEntry.Excel_Cell_Format.NotEmpty() ? descriptionEntry.Excel_Cell_Format : "",
             Color      = descriptionEntry.Background_Color.NotEmpty() ? descriptionEntry.Background_Color : "",
             TextColor  = descriptionEntry.Foreground_Color.NotEmpty() ? descriptionEntry.Foreground_Color : "",
             FontSize   = descriptionEntry.Font_Size
         });
         m_reportTable.WorkSheets[worksheetName].Add(newRow);  // add the new row to the table
     }
 }
Example #2
0
        private async Task <WebRequest> CreateEbayStandartPostRequestAsync(string url, Dictionary <string, string> headers, string body, string mark, CancellationToken cts)
        {
            if (cts.IsCancellationRequested)
            {
                return(null);
            }

            if (!headers.Exists(keyValuePair => keyValuePair.Key == EbayHeaders.XEbayApiCompatibilityLevel))
            {
                headers.Add(EbayHeaders.XEbayApiCompatibilityLevel, EbayHeadersValues.XEbayApiCompatibilityLevel);
            }

            if (!headers.Exists(keyValuePair => keyValuePair.Key == EbayHeaders.XEbayApiDevName))
            {
                headers.Add(EbayHeaders.XEbayApiDevName, this._ebayConfig.DevName);
            }

            if (!headers.Exists(keyValuePair => keyValuePair.Key == EbayHeaders.XEbayApiAppName))
            {
                headers.Add(EbayHeaders.XEbayApiAppName, this._ebayConfig.AppName);
            }

            if (!headers.Exists(keyValuePair => keyValuePair.Key == EbayHeaders.XEbayApiSiteid))
            {
                headers.Add(EbayHeaders.XEbayApiSiteid, this._userCredentials.SiteId.ToString());
            }

            return(await this._webRequestServices.CreateServicePostRequestAsync(url, body, headers, cts, mark).ConfigureAwait(false));
        }
Example #3
0
        public static void GetMovieData(ref Dictionary <string, MovieData> __result)
        {
            foreach (var movie in allTheMovies.Values)
            {
                if (__result.Exists(d => d.Value.Tags.Contains("CMovieID:" + movie.Id)))
                {
                    if (__result.Find(d => d.Value.Tags.Contains("CMovieID:" + movie.Id)) is KeyValuePair <string, MovieData> md && !PyTK.PyUtils.checkEventConditions(movie.Conditions, Game1.MasterPlayer))
                    {
                        __result.Remove(md.Key);
                    }

                    continue;
                }

                if (!PyTK.PyUtils.checkEventConditions(movie.Conditions, Game1.MasterPlayer))
                {
                    continue;
                }

                if (movie.FixedMovieID != null)
                {
                    MovieData fixedData = movie.GetFixedData();
                    fixedData.ID = movie.FixedMovieID;
                    __result.AddOrReplace(fixedData.ID, fixedData);
                    continue;
                }
            }
        }
        public static Item replaceItem(Item item)
        {
            if (!collection.Exists(c => c.Value.sdvId == item.ParentSheetIndex))
            {
                return(item);
            }

            return(collection.Find(c => c.Value.sdvId == item.ParentSheetIndex).Value.getObject());
        }
Example #5
0
        public async Task <WebRequest> CreateEbayStandartPostRequestWithCertAsync(string url, Dictionary <string, string> headers, string body, string mark, CancellationToken cts)
        {
            if (!headers.Exists(keyValuePair => keyValuePair.Key == EbayHeaders.XEbayApiCertName))
            {
                headers.Add(EbayHeaders.XEbayApiCertName, this._ebayConfig.CertName);
            }

            return(await this.CreateEbayStandartPostRequestAsync(url, headers, body, mark, cts).ConfigureAwait(false));
        }
Example #6
0
 private void addNewRowBetween(string worksheetName, TableDescriptionTableEntry descriptionEntry, Dictionary <string, string> record, int rowNumber)
 {
     if (descriptionEntry.Column_Number == 0)
     {
         // create a new row at the specified index with the value cell as the first cell
         m_reportTable.WorkSheets[worksheetName].Insert(
             new ExcelRow(new List <ExcelCell>()
         {
             new ExcelCell(
                 record.Exists(descriptionEntry.Access_Column_Name) ? record[descriptionEntry.Access_Column_Name].NotEmpty() ? record[descriptionEntry.Access_Column_Name] : "" : "")
             {
                 CellFormat = descriptionEntry.Excel_Cell_Format.NotEmpty() ? descriptionEntry.Excel_Cell_Format : "",
                 Color      = descriptionEntry.Background_Color.NotEmpty() ? descriptionEntry.Background_Color : "",
                 TextColor  = descriptionEntry.Foreground_Color.NotEmpty() ? descriptionEntry.Foreground_Color : "",
                 FontSize   = descriptionEntry.Font_Size
             }
         }), rowNumber);
     }
     else
     {
         int      blankColumns = descriptionEntry.Column_Number;
         ExcelRow currentRow   = new ExcelRow();      // create new blank row
         addBlankCells(ref currentRow, blankColumns); // add some blank cells to the new row
         currentRow.Add(new ExcelCell(
                            record.Exists(descriptionEntry.Access_Column_Name) ?
                            record[descriptionEntry.Access_Column_Name].NotEmpty() ? record[descriptionEntry.Access_Column_Name] : ""
             : "")
         {
             CellFormat = descriptionEntry.Excel_Cell_Format.NotEmpty() ? descriptionEntry.Excel_Cell_Format : "",
             Color      = descriptionEntry.Background_Color.NotEmpty() ? descriptionEntry.Background_Color : "",
             TextColor  = descriptionEntry.Foreground_Color.NotEmpty() ? descriptionEntry.Foreground_Color : "",
             FontSize   = descriptionEntry.Font_Size
         });
         m_reportTable.WorkSheets[worksheetName].Insert(currentRow, rowNumber);
     }
 }
Example #7
0
        /// <summary>
        /// Gets an attributeList from a ParseTreeNode.
        /// </summary>
        /// <param name="aChildNode">The interesting ParseTreeNode.</param>
        /// <param name="myTypeManager">the typemanager</param>
        /// <returns>A Dictionary with attribute definitions.</returns>
        private Dictionary<AttributeDefinition, String> GetAttributeList(ParseTreeNode aChildNode)
        {
            #region Data

            var attributes = new Dictionary<AttributeDefinition, String>();

            #endregion

            foreach (ParseTreeNode aAttrDefNode in aChildNode.ChildNodes)
            {
                AttributeDefinitionNode aAttrDef = (AttributeDefinitionNode)aAttrDefNode.AstNode;
                if (aAttrDef.AttributeDefinition.DefaultValue != null)
                {
                    if (aAttrDef.AttributeDefinition.AttributeType.TypeCharacteristics == null)
                    {
                        aAttrDef.AttributeDefinition.AttributeType.TypeCharacteristics = new TypeCharacteristics();
                    }
                    aAttrDef.AttributeDefinition.AttributeType.TypeCharacteristics.IsMandatory = true;
                }

                if (attributes.Exists(item => item.Key.AttributeName == aAttrDef.AttributeDefinition.AttributeName))
                    throw new GraphDBException(new Error_AttributeAlreadyExists(aAttrDef.AttributeDefinition.AttributeName));
                else
                    attributes.Add(aAttrDef.AttributeDefinition, aAttrDef.AttributeDefinition.AttributeType.Name);
            }

            return attributes;
        }
Example #8
0
 public bool CanEdit <T>(IAssetInfo asset)
 {
     return(Assets.Exists(a => asset.AssetNameEquals(a.Key)));
 }
Example #9
0
        private void reusePreviousRow(string worksheetName, TableDescriptionTableEntry descriptionEntry, Dictionary <string, string> record, int rowNumber)
        {
            ExcelRow currentRow = m_reportTable.WorkSheets[worksheetName][rowNumber - 1];

            if (descriptionEntry.Column_Number == 0)
            {
                if (currentRow[0] == null && currentRow.Count == 0)
                {
                    // the first cell does not exist and therefore needs to be created
                    currentRow.Add(new ExcelCell(
                                       record.Exists(descriptionEntry.Access_Column_Name) ? stringNotEmpty(record[descriptionEntry.Access_Column_Name]) ? record[descriptionEntry.Access_Column_Name] : "" : "")
                    {
                        CellFormat = stringNotEmpty(descriptionEntry.Excel_Cell_Format) ? descriptionEntry.Excel_Cell_Format : "",
                        Color      = stringNotEmpty(descriptionEntry.Background_Color) ? descriptionEntry.Background_Color : "",
                        TextColor  = stringNotEmpty(descriptionEntry.Foreground_Color) ? descriptionEntry.Foreground_Color : "",
                        FontSize   = descriptionEntry.Font_Size
                    });
                }
                else
                {
                    // the first cell will be replaced
                    currentRow[0].Value =
                        record.Exists(descriptionEntry.Access_Column_Name) ? stringNotEmpty(record[descriptionEntry.Access_Column_Name]) ? record[descriptionEntry.Access_Column_Name] : "" : "";
                    currentRow[0].TextColor  = stringNotEmpty(descriptionEntry.Foreground_Color) ? descriptionEntry.Foreground_Color : "";
                    currentRow[0].Color      = stringNotEmpty(descriptionEntry.Background_Color) ? descriptionEntry.Background_Color : "";
                    currentRow[0].CellFormat = stringNotEmpty(descriptionEntry.Excel_Cell_Format) ? descriptionEntry.Excel_Cell_Format : "";
                    currentRow[0].FontSize   = descriptionEntry.Font_Size;
                }
            }
            else if (descriptionEntry.Column_Number > 0)
            {
                if (descriptionEntry.Column_Number > currentRow.Count)
                {
                    int blankColumns = descriptionEntry.Column_Number - currentRow.Count;
                    // Example: | 123 | 456 | BlankCell | BlankCell | NewValue |
                    // currentRow.Count = 2
                    // blankColumns = descriptionEntry.Column_Number - currentRow.Count = 4 - 2 = 2
                    // blankColumns = 2
                    // Add 2 new blank cells/columns
                    addBlankCells(ref currentRow, blankColumns);

                    currentRow.Add(new ExcelCell(record.Exists(descriptionEntry.Access_Column_Name) ? stringNotEmpty(record[descriptionEntry.Access_Column_Name]) ? record[descriptionEntry.Access_Column_Name] : "" : "")
                    {
                        CellFormat = stringNotEmpty(descriptionEntry.Excel_Cell_Format) ? descriptionEntry.Excel_Cell_Format : "",
                        Color      = stringNotEmpty(descriptionEntry.Background_Color) ? descriptionEntry.Background_Color : "",
                        TextColor  = stringNotEmpty(descriptionEntry.Foreground_Color) ? descriptionEntry.Foreground_Color : "",
                        FontSize   = descriptionEntry.Font_Size
                    });
                }
                else if (descriptionEntry.Column_Number < currentRow.Count)
                {
                    // cell somewhere in the middle should be replaced:
                    // index = descriptionEntry.Column_Number
                    // length = currentRow.Count
                    // index < length
                    currentRow[descriptionEntry.Column_Number].Value =
                        record.Exists(descriptionEntry.Access_Column_Name) ? stringNotEmpty(record[descriptionEntry.Access_Column_Name]) ? record[descriptionEntry.Access_Column_Name] : "" : "";
                    currentRow[descriptionEntry.Column_Number].TextColor  = stringNotEmpty(descriptionEntry.Foreground_Color) ? descriptionEntry.Foreground_Color : "";
                    currentRow[descriptionEntry.Column_Number].Color      = stringNotEmpty(descriptionEntry.Background_Color) ? descriptionEntry.Background_Color : "";
                    currentRow[descriptionEntry.Column_Number].CellFormat = stringNotEmpty(descriptionEntry.Excel_Cell_Format) ? descriptionEntry.Excel_Cell_Format : "";
                    currentRow[descriptionEntry.Column_Number].FontSize   = descriptionEntry.Font_Size;
                }
                else if (currentRow.Count == descriptionEntry.Column_Number)
                {
                    // there should be added a new cell to the end of the row
                    currentRow.Add(new ExcelCell(
                                       record.Exists(descriptionEntry.Access_Column_Name) ? stringNotEmpty(record[descriptionEntry.Access_Column_Name]) ? record[descriptionEntry.Access_Column_Name] : "" : "")
                    {
                        CellFormat = stringNotEmpty(descriptionEntry.Excel_Cell_Format) ? descriptionEntry.Excel_Cell_Format : "",
                        Color      = stringNotEmpty(descriptionEntry.Background_Color) ? descriptionEntry.Background_Color : "",
                        TextColor  = stringNotEmpty(descriptionEntry.Foreground_Color) ? descriptionEntry.Foreground_Color : "",
                        FontSize   = descriptionEntry.Font_Size
                    });
                }
            }
        }
Example #10
0
        /// <summary>
        /// Testowanie prędkości:
        ///		* Ładowanie słownika
        ///		* Wyszukiwanie istnienia słów:
        ///			- ęą
        ///			- żyznościach
        ///			- żywotopisarstwa
        ///			- dwuwiosłowymi
        ///			- żżż
        ///		* Dopasowanie:
        ///			- żyźnicom do m @ 7, cionyźż
        ///			- żyźnicom do m @ 7, cio yźż
        /// </summary>
        /// <param name="D">Implementacja słownika do przetestowania</param>
        public static void Benchmark1(Dictionary D)
        {
            System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch();

            Console.WriteLine("=== {0} ===", D.GetType().Name);

            ///////////////////////////////////////////////////////////

            SW.Restart();
            D.Reload();
            SW.Stop();

            Console.WriteLine("Load: {0}ms", SW.ElapsedMilliseconds);

            ///////////////////////////////////////////////////////////

            String[] FindWords = new string[] { "ęą", "żyznościach", "żywotopisarstwa", "dwuwiosłowymi", "żżż" };

            foreach(String FindWord in FindWords)
            {
                SW.Restart();
                bool Result = D.Exists(FindWord);
                SW.Stop();
                Console.WriteLine("Exists: '{0}': {1}ms ({2})", FindWord, SW.ElapsedMilliseconds, Result);
            }

            ///////////////////////////////////////////////////////////

            Dictionary.AlreadySetLetters ASL = new Dictionary.AlreadySetLetters();
            ASL.Set(7, 'm');

            Dictionary.HeldCharacters HC1 = new Dictionary.HeldCharacters(D.GetDictionaryEncoding());
            HC1.Add("cionyźż");

            Dictionary.HeldCharacters HC2 = new Dictionary.HeldCharacters(D.GetDictionaryEncoding());
            HC2.Add("cio yźż");

            SW.Restart();
            Dictionary.WordsFound WF1 = D.Find(ASL, HC1);
            SW.Stop();

            Console.WriteLine("Find1 (m): {0}ms ({1})", SW.ElapsedMilliseconds, WF1.Count);

            SW.Restart();
            Dictionary.WordsFound WF2 = D.Find(ASL, HC2);
            SW.Stop();

            Console.WriteLine("Find2 (blank): {0}ms ({1})", SW.ElapsedMilliseconds, WF2.Count);

            ///////////////////////////////////////////////////////////

            foreach(Dictionary.WordFound WF in WF1)
                Console.Write(WF.GetWord() + ", ");

            Console.WriteLine();
            Console.WriteLine();

            foreach(Dictionary.WordFound WF in WF2)
                Console.Write(WF.GetWord() + ", ");

            ///////////////////////////////////////////////////////////

            Console.WriteLine();
        }