private void button1_Click(object sender, RoutedEventArgs e)
        {
            if ("".Equals(cboNamespace.Text))
            {
                MessageBox.Show("Enter a namespace first");
                return;
            }

            // save namespaces
            try
            {
                System.Collections.Specialized.StringCollection strColl = new System.Collections.Specialized.StringCollection();

                foreach (string s in cboNamespace.Items.SourceCollection )
                {
                    if (s.Length > 0)
                    {
                        strColl.Add(s);
                    }
                }
                if (!strColl.Contains(cboNamespace.Text))
                {
                    strColl.Insert(0,cboNamespace.Text);
                }
                DictionaryInspector.Properties.Settings.Default.selectedNamespaces = strColl;
                DictionaryInspector.Properties.Settings.Default.Save();
            }
            catch
            {
            }

            // open window
            MainWindow window = new MainWindow(cboNamespace.Text, int.Parse(txtPort.Text));
            window.Show();
            this.Close();
        }
示例#2
0
        public void AddMembersAndRemoveSiblings(System.Collections.Specialized.StringCollection UniqueNames, bool MultiSelect)
        {
            if (MultiSelect)
            {
                for (int j = 0; j < _report.Axes.Count; j++)
                {
                    for (int i = 0; i < _report.Axes[j].Hierarchies.Count; i++)
                    {
                        Hierarchy hier = _report.Axes[j].Hierarchies[i];
                        if (hier.IsOpen)
                        {
                            bool IsAggregateHierarchy = (hier.Axis.Ordinal == 2 && hier.FilterMember is MembersAggregate?true:false);                         //only aggregate can be multi-selected

                            if (IsAggregateHierarchy == false && hier.Axis.Ordinal == 2)
                            {
                                continue;                                 //beacuse if MultiSelect memebrs are  not applicable to non-aggr hier on filter
                            }
//							AddMembersAndRemoveSiblings(hier.SchemaMembers, UniqueNames ,  IsAggregateHierarchy); //it's not filter OR aggr hier on filter
                            // deal with schema members
                            SortedList reAddMembers = new SortedList();
                            this.RecursiveRemoveMembers(hier.SchemaMembers, IsAggregateHierarchy, ref reAddMembers);
                            this.AddMembers(hier, UniqueNames, reAddMembers);

                            // deal with calc members
                            if (IsAggregateHierarchy)
                            {
                                MembersAggregate maggr = hier.FilterMember as MembersAggregate;
                                if (maggr != null)
                                {
                                    for (int n = 0; n < maggr.Members.Count; n++)
                                    {
                                        if (UniqueNames.Contains(maggr.Members[n].UniqueName) == false)
                                        {
                                            maggr.Members.RemoveAt(n);
                                            n--;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int n = 0; n < hier.CalculatedMembers.Count; n++)
                                {
                                    if (UniqueNames.Contains(hier.CalculatedMembers[n].UniqueName) == false)
                                    {
                                        hier.CalculatedMembers.RemoveAt(n);
                                        n--;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // axis2
                // UniqueNames are actually Identifiers
                for (int i = 0; i < UniqueNames.Count; i++)
                {
                    SchemaMember mem = this.SchemaMemberFromIdentifier(UniqueNames[i]);
                    if (mem != null)
                    {
                        mem.Hierarchy.AddMember(mem, true);
                    }
                }
            }
        }
 /// <summary>
 /// Refreshes Modules manager informations
 /// </summary>
 /// <remarks>
 /// Is mainly nead to execute when in Ice locator
 /// (IceGrid) are new instances of
 /// <see cref="T:Ferda.Modules.BoxModuleFactoryCreatorPrx"/>
 /// </remarks>
 public void Refresh()
 {
     this.Helper.ManagersEngineI.ManagersLocatorI.Refresh();
     System.Collections.Specialized.StringCollection usedKeys
         = new System.Collections.Specialized.StringCollection();
     Debug.WriteLine("Refreshing Creators...");
     //TODO udelat lepe - co kdyz se zmeni server na kterem bezi moduly?!
     creatorPrxs = this.lnkHelper.ManagersEngineI.ManagersLocatorI.BoxModuleFactoryCreatorsByIdentifier;
     foreach(KeyValuePair<string,Ferda.Modules.BoxModuleFactoryCreatorPrx> val in creatorPrxs)
     {
         if(!boxModuleFactoryCreators.ContainsKey(val.Key))
             boxModuleFactoryCreators[val.Key] = new BoxModuleFactoryCreator(this.lnkHelper,val.Value, this, helpFiles);
         usedKeys.Add(val.Key);
     }
     foreach(string key in creatorPrxs.Keys)
     {
         if(!usedKeys.Contains(key)) boxModuleFactoryCreators.Remove(key);
     }
     boxModuleFactoryCreators[groupCreator.Identifier] = groupCreator;
 }
        public static ParsedObjectFile ParseObjectFile(string ObjectFilePath)
        {
            ParsedObjectFile Result = null;

            // Fixed structure sizes
            int SizeofCOFFFileHeader   = 20;
            int SizeofSectionHeader    = 40;
            int SizeofSymbolTableEntry = 18;
            int SizeofRelocationEntry  = 10;

            // Open the object file for reading
            using (FileStream FileStream = System.IO.File.OpenRead(ObjectFilePath))
            {
                long FileLength = FileStream.Length;

                if (FileLength < SizeofCOFFFileHeader)
                {
                    // You cannot parse the COFF header if the file is not big enough to contain a COFF header.
                    throw new Exception("ObjectFile is too small to store a COFF header.");
                }

                // Open a BinaryReader object for the object file
                using (BinaryReader BinaryReader = new System.IO.BinaryReader(FileStream))
                {
                    // Parse the COFF header
                    COFF.HEADER CoffHeader = new COFF.HEADER(BinaryReader);

                    if (CoffHeader.SizeOfOptionalHeader != 0)
                    {
                        // Per the PECOFF specification, an object file does not have an optional header
                        throw new Exception("Coff header indicates the existence of an optional header. An object file cannot have an optional header.");
                    }

                    if (CoffHeader.PointerToSymbolTable == 0)
                    {
                        throw new Exception("An object file is supposed to have a symbol table.");
                    }

                    if (FileLength < ((CoffHeader.NumberOfSections * SizeofSectionHeader) + SizeofCOFFFileHeader))
                    {
                        // The object file isn't big enough to store the number of sections present.
                        throw new Exception("ObjectFile is too small to store section header data.");
                    }

                    // A string collection used to store section header names. This collection is referenced while
                    // parsing the symbol table entries whose name is the same as the section header. In this case,
                    // the symbol entry will have a particular auxiliary symbol table entry.
                    System.Collections.Specialized.StringCollection SectionHeaderNames = new System.Collections.Specialized.StringCollection();

                    // Correlate the processor type to the relocation type. There are more relocation type defined
                    // in the PECOFF specification, but I don't expect those to be present. In that case, relocation
                    // entries default to X86RelocationType.
                    COFF.SECTION_HEADER[] SectionHeaders = new COFF.SECTION_HEADER[CoffHeader.NumberOfSections];

                    // Parse section headers
                    for (int i = 0; i < CoffHeader.NumberOfSections; i++)
                    {
                        SectionHeaders[i] = new COFF.SECTION_HEADER(BinaryReader);

                        // Add the section name to the string collection. This will be referenced during symbol table parsing.
                        SectionHeaderNames.Add(SectionHeaders[i].Name);

                        // Save the current filestream position. We are about to jump out of place.
                        long SavedFilePosition = FileStream.Position;

                        // Check to see if the raw data points beyond the actual file size
                        if ((SectionHeaders[i].PointerToRawData + SectionHeaders[i].SizeOfRawData) > FileLength)
                        {
                            throw new Exception("Section header's raw data exceeds the size of the object file.");
                        }
                        else
                        {
                            // Read the raw data into a byte array
                            FileStream.Seek(SectionHeaders[i].PointerToRawData, SeekOrigin.Begin);
                            SectionHeaders[i].RawData = BinaryReader.ReadBytes((int)SectionHeaders[i].SizeOfRawData);
                        }

                        // Check to see if the section has a relocation table
                        if ((SectionHeaders[i].PointerToRelocations != 0) && (SectionHeaders[i].NumberOfRelocations != 0))
                        {
                            // Check to see if the relocation entries point beyond the actual file size
                            if ((SectionHeaders[i].PointerToRelocations + (SizeofRelocationEntry * SectionHeaders[i].NumberOfRelocations)) > FileLength)
                            {
                                throw new Exception("(SectionHeaders[i].Name) section header's relocation entries exceeds the soze of the object file.");
                            }

                            FileStream.Seek(SectionHeaders[i].PointerToRelocations, SeekOrigin.Begin);

                            COFF.RelocationEntry[] Relocations = new COFF.RelocationEntry[SectionHeaders[i].NumberOfRelocations];

                            for (int j = 0; j < SectionHeaders[i].NumberOfRelocations; j++)
                            {
                                Relocations[j] = new COFF.RelocationEntry(BinaryReader);
                                // Cast the relocation as its respective type
                                switch (CoffHeader.Machine)
                                {
                                case Machine.I386:
                                    Relocations[j].Type = (COFF.X86RelocationType)Relocations[j].Type;
                                    break;

                                case Machine.AMD64:
                                    Relocations[j].Type = (COFF.AMD64RelocationType)Relocations[j].Type;
                                    break;

                                case Machine.ARMV7:
                                    Relocations[j].Type = (COFF.ARMRelocationType)Relocations[j].Type;
                                    break;

                                case Machine.ARM64:
                                    Relocations[j].Type = (COFF.ARMv8RelocationType)Relocations[j].Type;
                                    break;
                                }
                            }

                            // Add the relocation table entry to the section header
                            SectionHeaders[i].Relocations = Relocations;
                        }

                        // Restore the original filestream pointer
                        FileStream.Seek(SavedFilePosition, SeekOrigin.Begin);
                    }

                    // Retrieve the contents of the COFF string table
                    long SymTableSize      = CoffHeader.NumberOfSymbols * SizeofSymbolTableEntry;
                    long StringTableOffset = CoffHeader.PointerToSymbolTable + SymTableSize;

                    if (StringTableOffset > FileLength)
                    {
                        throw new Exception("The string table points beyond the end of the file.");
                    }

                    FileStream.Seek(StringTableOffset, SeekOrigin.Begin);
                    UInt32 StringTableLength = BinaryReader.ReadUInt32();

                    if (StringTableLength > FileLength)
                    {
                        throw new Exception("The string table's length exceeds the length of the file.");
                    }

                    string StringTable = System.Text.Encoding.UTF8.GetString(BinaryReader.ReadBytes((int)StringTableLength));

                    COFF.SYMBOL_TABLE[] RawSymbolTable = new COFF.SYMBOL_TABLE[CoffHeader.NumberOfSymbols];

                    // Retrieve the symbol table
                    if (FileLength < StringTableOffset)
                    {
                        throw new Exception("Symbol table is larger than the file size.");
                    }

                    FileStream.Seek(CoffHeader.PointerToSymbolTable, SeekOrigin.Begin);
                    int NumberofRegularSymbols = 0;

                    /*
                     *  Go through each symbol table looking for auxiliary symbols to parse
                     *
                     *  Currently supported auxiliary symbol table entry formats:
                     *  1) .file
                     *  2) Entry names that match the name of a section header
                     */

                    for (int i = 0; i < CoffHeader.NumberOfSymbols; i++)
                    {
                        // Parse the symbol tables regardless of whether they are normal or auxiliary symbols
                        RawSymbolTable[i] = new COFF.SYMBOL_TABLE(BinaryReader);

                        if (RawSymbolTable[i].NumberOfAuxSymbols == 0)
                        {
                            // This symbol table entry has no auxiliary symbols
                            NumberofRegularSymbols++;
                        }
                        else if (RawSymbolTable[i].Name == ".file")
                        {
                            long TempPosition = FileStream.Position; // Save filestream position
                            // Retrieve the file name
                            RawSymbolTable[i].AuxSymbols = System.Text.Encoding.UTF8.GetString(BinaryReader.ReadBytes(RawSymbolTable[i].NumberOfAuxSymbols * SizeofSymbolTableEntry)).TrimEnd(((Char)0));
                            FileStream.Seek(TempPosition, SeekOrigin.Begin); // Restore filestream position
                        }
                        else if (SectionHeaderNames.Contains(RawSymbolTable[i].Name))
                        {
                            long TempPosition = FileStream.Position;         // Save filestream position
                            RawSymbolTable[i].AuxSymbols = new COFF.SECTION_DEFINITION(BinaryReader);
                            FileStream.Seek(TempPosition, SeekOrigin.Begin); // Restore filestream position
                        }
                    }

                    // Create an array of symbol table entries without auxiliary table entries
                    COFF.SYMBOL_TABLE[] SymbolTable = new COFF.SYMBOL_TABLE[NumberofRegularSymbols];
                    int k = 0;

                    for (int i = 0; i < CoffHeader.NumberOfSymbols; i++)
                    {
                        SymbolTable[k] = RawSymbolTable[i]; // FYI, the first symbol table entry will never be an aux symbol
                        k++;

                        // Skip over the auxiliary symbols
                        if (RawSymbolTable[i].NumberOfAuxSymbols != 0)
                        {
                            i += RawSymbolTable[i].NumberOfAuxSymbols;
                        }
                    }

                    // Fix the section names if any of them point to the COFF string table
                    for (int i = 0; i < CoffHeader.NumberOfSections; i++)
                    {
                        if ((SectionHeaders[i].Name != null) && (SectionHeaders[i].Name.IndexOf('/') == 0))
                        {
                            string StringTableIndexString = SectionHeaders[i].Name.Substring(1);

                            int StringTableIndex;
                            if (int.TryParse(StringTableIndexString, out StringTableIndex))
                            {
                                StringTableIndex -= 4;

                                if (StringTableIndex > (StringTableLength + 4))
                                {
                                    throw new Exception("String table entry exceeds the bounds of the object file.");
                                }

                                int Length = StringTable.IndexOf(((Char)0), StringTableIndex);
                                SectionHeaders[i].Name = StringTable.Substring(StringTableIndex, Length);
                            }
                        }
                    }

                    // Fix the symbol table names
                    for (int i = 0; i < SymbolTable.Length; i++)
                    {
                        if ((SymbolTable[i].Name != null) && (SymbolTable[i].Name.IndexOf('/') == 0))
                        {
                            string StringTableIndexString = SymbolTable[i].Name.Substring(1);

                            int StringTableIndex;
                            if (int.TryParse(StringTableIndexString, out StringTableIndex))
                            {
                                StringTableIndex -= 4;
                                int Length = StringTable.IndexOf(((Char)0), StringTableIndex) - StringTableIndex;
                                SymbolTable[i].Name = StringTable.Substring(StringTableIndex, Length);
                            }
                        }
                    }

                    // Apply symbol names to the relocation entries
                    // SectionHeaders | Where-Object { _.Relocations } | % {
                    //     _.Relocations | % { _.Name = RawSymbolTable[_.SymbolTableIndex].Name }
                    // }
                    SectionHeaders.Where(h => (h.Relocations != null)).ToList().ForEach(h => h.Relocations.ToList().ForEach(r => r.Name = RawSymbolTable[r.SymbolTableIndex].Name));

                    Result                = new ParsedObjectFile();
                    Result.CoffHeader     = CoffHeader;
                    Result.SectionHeaders = SectionHeaders;
                    Result.SymbolTable    = SymbolTable;
                }
            }

            return(Result);
        }
示例#5
0
        static private void AddPredifinedConvertion(Type systemtype, Type[] from, Type[] to)
        {
            if (!_checkedTypes.Contains(systemtype.FullName))
            {
                lock (_lockConst)
                {
                    if (!_checkedTypes.Contains(systemtype.FullName))
                    {
                        _checkedTypes.Add(systemtype.FullName);
                    }
                }
            }

            ThisIsKnownType(systemtype);

            System.Collections.Specialized.StringCollection sl;
            if (!_canConvertTo.ContainsKey(systemtype.FullName))
            {
                lock (_lockConst)
                {
                    if (!_canConvertTo.ContainsKey(systemtype.FullName))
                    {
                        _canConvertTo.Add(systemtype.FullName, new System.Collections.Specialized.StringCollection());
                    }
                }
            }

            sl = (System.Collections.Specialized.StringCollection)_canConvertTo[systemtype.FullName];

            for (int i = 0; i < to.Length; i++)
            {
                ThisIsKnownType(to[i]);
                if (!sl.Contains(to[i].FullName))
                {
                    lock (_lockConst)
                    {
                        if (!sl.Contains(to[i].FullName))
                        {
                            sl.Add(to[i].FullName);
                        }
                    }
                }
            }

            for (int i = 0; i < from.Length; i++)
            {
                ThisIsKnownType(from[i]);
                if (!_canConvertTo.ContainsKey(from[i].FullName))
                {
                    lock (_lockConst)
                    {
                        if (!_canConvertTo.ContainsKey(from[i].FullName))
                        {
                            _canConvertTo.Add(from[i].FullName, new System.Collections.Specialized.StringCollection());
                        }
                    }
                }

                sl = (System.Collections.Specialized.StringCollection)_canConvertTo[from[i].FullName];

                if (!sl.Contains(systemtype.FullName))
                {
                    lock (_lockConst)
                    {
                        if (!sl.Contains(systemtype.FullName))
                        {
                            sl.Add(systemtype.FullName);
                        }
                    }
                }
            }
        }
        public void Remove(System.Collections.Specialized.StringCollection Identifiers)
        {
            ArrayList memList=new ArrayList();

            for(int i=0;i<Identifiers.Count;i++)
            {
                short axisOrdinal=-1;
                int pos=-1;
                int mpos=-1;
                this.CellsetPositionFromIdentifier(Identifiers[i] , ref axisOrdinal , ref pos, ref mpos);

                CellsetMember cstMem=_report.Cellset.GetCellsetMember( (byte)axisOrdinal  , mpos, pos);
                memList.Add(cstMem);
            }

            // remove members
            System.Collections.Specialized.StringCollection parentList=new System.Collections.Specialized.StringCollection();
            for(int i=0;i<memList.Count;i++)
            {
                CellsetMember cstMem=(CellsetMember)memList[i];
                Hierarchy hier=_report.Schema.GetHierarchyFromMemberUniqueName(cstMem.UniqueName);

                // get member, remove if exisits
                DataMember dmem=(DataMember)hier.GetMember(cstMem.UniqueName);
                if(dmem!=null)
                {
                    dmem.Hierarchy.RemoveMember(dmem);
                    continue;
                }

                // if not found by unique name, check if member was part of MemberChildrenSet (autoselect),
                // in this case we convert it to not-autoselect
                if(cstMem.LevelDepth==0)
                    continue;
                SchemaMember parentMem=_report.Schema.GetMemberParent(hier, cstMem.UniqueName);
                if(parentMem!=null)
                {
                    if(parentList.Contains(parentMem.UniqueName))
                        continue; // parent already handled

                    parentList.Add(parentMem.UniqueName);
                    MemberChildrenSet mcs=hier.CalculatedMembers.GetMemberChildrenSet(parentMem.UniqueName);
                    if(mcs!=null)
                    {
                        // add children
                        hier.RemoveMember(mcs);
                        hier.AddMemberChildren(parentMem.UniqueName, false);
                    }
                }
            }

            // finally remove members
            for(int i=0;i<memList.Count;i++)
            {
                CellsetMember cstMem=(CellsetMember)memList[i];
                Hierarchy hier=_report.Schema.GetHierarchyFromMemberUniqueName(cstMem.UniqueName);

                hier.DataMembers.Remove(cstMem.UniqueName);
            }
        }
        /// <summary>
        /// Inner method used to implement the setup operation.  
        /// </summary>
        protected void InnerSetup(Config config)
        {
            // if needed, clear the prior state.
            if (setupPerformed)
                Clear();

            // record the given configuration
            this.config = config;
            excludedFileSet = new System.Collections.Specialized.StringCollection();
            excludedFileSet.AddRange(config.excludeFileNamesSet.ToArray());

            string dirPath = config.dirPath;

            // try to add a DirectoryEntryInfo record for each of the files that are in the directory
            try
            {
                DirectoryEntryInfo basePathInfo = new DirectoryEntryInfo(dirPath);

                if (basePathInfo.Exists)
                {
                    if (basePathInfo.IsFile)
                        throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not specify a directory.", dirPath));
                }
                else
                {
                    if (config.createDirectoryIfNeeded)
                        System.IO.Directory.CreateDirectory(dirPath);
                    else
                        throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not exist.", dirPath));
                }

                // directory exists or has been created - now scan it and record each of the entries that are found therein
                DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
                FileSystemInfo [] directoryFSIArray = dirInfo.GetFileSystemInfos();

                foreach (FileSystemInfo fsi in directoryFSIArray)
                {
                    string path = fsi.FullName;
                    string name = fsi.Name;

                    if (!excludedFileSet.Contains(name) && !excludedFileSet.Contains(path))
                        AddDirEntry(path, true);
                }

                if (numBadDirEntries != 0)
                    logger.Error.Emit("Setup Failure: There are bad directory entries in dir '{0}'", dirPath);
            }
            catch (SetupFailureException sfe)
            {
                SetSetupFaultCode(sfe.Message);
            }
            catch (System.Exception ex)
            {
                SetSetupFaultCode(Utils.Fcns.CheckedFormat("Setup Failure: encountered unexpected exception '{0}' while processing dir '{1}'", ex.Message, dirPath));
            }

            if (!SetupFailed)
            {
                // perform an additional set of tests
                if (string.IsNullOrEmpty(config.fileNamePrefix) || string.IsNullOrEmpty(config.fileNameSuffix))
                    SetSetupFaultCode("Setup Failure: Invalid file name fields in configuration");
                else if (config.advanceRules.fileAgeLimitInSec < 0.0)
                    SetSetupFaultCode("Setup Failure: Config: advanceRules.fileAgeLimitInSec is negative");
                else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit < ConfigPurgeNumFilesMinValue)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too small");
                else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit > ConfigPurgeNumFilesMaxValue)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too large");
                else if (config.purgeRules.dirTotalSizeLimit < 0)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirTotalSizeLimit is negative");
                else if (config.purgeRules.fileAgeLimitInSec < 0.0)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.maxFileAgeLimitInSec is negative");
            }

            DirectoryEntryInfo activeFileInfo = new DirectoryEntryInfo();

            if (!SetupFailed)
            {
                switch (config.fileNamePattern)
                {
                case FileNamePattern.ByDate:				numFileNumberDigits = 0; break;
                case FileNamePattern.Numeric2DecimalDigits:	numFileNumberDigits = 2; maxFileNumber = 100; break;
                case FileNamePattern.Numeric3DecimalDigits:	numFileNumberDigits = 3; maxFileNumber = 1000; break;
                case FileNamePattern.Numeric4DecimalDigits:	numFileNumberDigits = 4; maxFileNumber = 10000; break;
                default: SetSetupFaultCode("Setup Failure: Invalid file name pattern in configuration"); break;
                }

                // go through the directory file info entries (acquired above) from newest to oldest
                //	and retain the newest valid file that matches the name pattern for this content
                //	manager.  This file will become the initial active file.

                activeFileEntryID = DirEntryID_Invalid;
                activeFileNumber = 0;
                bool matchFound = false;

                IList<Int64> itemKeys = dirEntryIDListSortedByCreatedFTimeUtc.Keys;
                IList<List<int>> itemValues = dirEntryIDListSortedByCreatedFTimeUtc.Values;

                for (int idx = dirEntryIDListSortedByCreatedFTimeUtc.Count - 1; !matchFound && idx >= 0; idx--)
                {
                    Int64 itemFTime = itemKeys[idx];
                    List<int> itemEntryIDList = itemValues[idx];

                    foreach (int itemEntryID in itemEntryIDList)
                    {
                        activeFileEntryID = itemEntryID;

                        if (IsDirEntryIDValid(activeFileEntryID))
                            activeFileInfo = dirEntryList[activeFileEntryID];
                        else
                        {
                            activeFileInfo.Clear();
                            Utils.Asserts.TakeBreakpointAfterFault("Setup: entry ID in ListSortedByCreated is not valid");
                            continue;
                        }

                        // verify that the entry is a file
                        if (!activeFileInfo.IsFile)
                        {
                            Utils.Asserts.TakeBreakpointAfterFault("Setup: entry ID in ListSortedByCreated is not a file");
                            continue;
                        }

                        // divide the name into prefix, middle and suffix fields

                        string fileName = activeFileInfo.Name;
                        bool fileNameIsValidMatch = true;

                        int fileNamePrefixLen = config.fileNamePrefix.Length;
                        int fileNameSuffixLen = config.fileNameSuffix.Length;

                        int split1Idx = Math.Min(fileNamePrefixLen, fileName.Length);   // prevent attempting to call Substring with a second arg that is beyond the end of the string.
                        string prefix = fileName.Substring(0, split1Idx);
                        string rest = fileName.Substring(split1Idx);
                        int restLen = rest.Length;

                        string middle = string.Empty, suffix = string.Empty;

                        if (restLen >= fileNameSuffixLen)
                        {
                            int splitPoint = restLen - fileNameSuffixLen;

                            middle = rest.Substring(0, splitPoint);
                            suffix = rest.Substring(splitPoint);
                        }
                        else
                        {
                            // this file name does not match requirements - exclude from search for current active file
                            fileNameIsValidMatch = false;
                        }

                        // test if the prefix and suffix's match
                        if (prefix != config.fileNamePrefix || suffix != config.fileNameSuffix)
                            fileNameIsValidMatch = false;

                        // test if the middle is valid
                        if (numFileNumberDigits > 0)
                        {
                            int testFileNumber = -1;
                            bool match = int.TryParse(middle, out testFileNumber);

                            if (testFileNumber >= 0 && middle.Length == numFileNumberDigits && match)
                                activeFileNumber = testFileNumber;
                            else
                                fileNameIsValidMatch = false;
                        }
                        else
                        {
                            // for FileNamePattern.ByDate files, we assume that the middle is valid if it is not empty
                            if (middle.Length == 0)
                                fileNameIsValidMatch = false;
                        }

                        matchFound = fileNameIsValidMatch;
                        if (matchFound)
                            break;
                    }
                }

                if (!matchFound && dirEntryIDListSortedByCreatedFTimeUtc.Count != 0)
                    logger.Warning.Emit("Setup Warning: no valid active file found in non-empty directory '{0}'", dirPath);
            }

            if (!SetupFailed && config.enableAutomaticCleanup)
            {
                for (int limit = 0; IsDirectoryCleanupNeeded && (limit < config.maxAutoCleanupDeletes); limit++)
                    PerformIncrementalCleanup();
            }

            if (SetupFailed)
            {
                logger.Error.Emit("Directory is not usable: path:'{0}' fault:'{1}'", dirPath, setupFaultCode);
            }
            else
            {
                logger.Debug.Emit("Directory is usable: path:'{0}' number of files:{1} active file:'{2}'",
                                            dirPath, dirEntryIDListSortedByName.Count, activeFileInfo.Name);
            }

            setupPerformed = true;
        }
        private Guid RegisterSubject(string name, string[] additionalOperations, string username)
        {
            Logger.Debug("Registered subject " + name);

            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForWriting))
            {
                SecuritySubject subject;
                if (!subjects.ContainsKey(name))
                {
                    if (username == null)
                        subjects[name] = new SecuritySubject(name);
                    else
                        subjects[name] = new SecuritySubject(name, username);
                }

                subject = subjects[name];

                Guid guid = Guid.NewGuid();

                while (acls.ContainsKey(guid))
                    guid = Guid.NewGuid();

                acls.Add(guid, subject);

                if (additionalOperations != null)
                {
                    Logger.Debug("Additional operations " + string.Join(", ", additionalOperations));
                    System.Collections.Specialized.StringCollection operations = new System.Collections.Specialized.StringCollection();
                    operations.AddRange(additionalOperations);

                    foreach (string op in operations)
                    {
                        if (!subject.HaveOperation(op))
                            subject.AddOperation(op);
                    }
                    operations.Add(Operation.DEFAULT_OPERATION);
                    foreach (string op in subject.GetOperations())
                    {
                        if (!operations.Contains(op))
                            subject.RemoveOperation(op);
                    }
                }
                return guid;
            }
        }
 public bool AllowPattern(string patternName)
 {
     return(_allowedPatterns.Contains(patternName));
 }
 /// <summary>
 /// Says if some creator has function with specified ice identifier
 /// </summary>
 /// <param name="iceId">Ice identifier</param>
 /// <param name="creator">Proxy of box module factory creator</param>
 /// <returns></returns>
 public bool IsWithIceId(string iceId, BoxModuleFactoryCreatorPrx creator)
 {
     System.Collections.Specialized.StringCollection _functionsIceIds =
     new System.Collections.Specialized.StringCollection();
     _functionsIceIds.AddRange(
         creator.getBoxModuleFunctionsIceIds());
     return _functionsIceIds.Contains(iceId);
 }
示例#11
0
        public static List <List <string> > ReadData(string importFile, int SheetIndex, string columnIndexStart, string columnIndexEnd, bool ignoreHeader, System.Collections.Specialized.StringCollection dateTimeColumns, int IgnoreEmptyRows)
        {
            Application xlsApp = CheckSettings(importFile, columnIndexStart, columnIndexEnd);

            List <List <string> > data = new List <List <string> >();

            Console.WriteLine("Import {0} FROM {1} to {2}", importFile, columnIndexStart, columnIndexEnd);

            Workbook xlsfile;

            string ConfiCulture = ExcelImport.Properties.Settings.Default.Culture;

            if (string.IsNullOrEmpty(ConfiCulture))
            {
                ConfiCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
            }

            System.Globalization.CultureInfo systemCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ConfiCulture);

            //Nachfolgender try catch wurde hinterlegt, da bei manchen Excel-Dateien das öffnen des Workbooks mit
            //allen Parametern nicht funktioniert. Daher versucht die Anwendung im ersten Schritt das öffnen mit
            //allen Parametern. Im zweiten Schritt wird die Datei übergeben.
            //Aufgefallen xlsx Dateien AnD
            try
            {
                xlsfile = xlsApp.Workbooks.Open(
                    importFile,
                    0,
                    true,
                    5,
                    string.Empty,
                    string.Empty,
                    true,
                    XlPlatform.xlWindows,
                    string.Empty,
                    false,
                    false,
                    0,
                    false,
                    true,
                    false);
            }
            catch
            {
                xlsfile = xlsApp.Workbooks.Open(importFile);
            }


            Worksheet ws = (Worksheet)xlsfile.Sheets[SheetIndex];


            int ZaehlerLeerZeilen = 0;
            int i = 1;

            while (true)
            {
                string index_start = columnIndexStart + i;
                string index_end   = columnIndexEnd + i;

                i++;

                List <string> lineContent = new List <string>();

                Range excelLine = ws.get_Range(index_start, index_end);

                Array array = (Array)excelLine.Cells.Value2;

                if (excelLine == null || excelLine.Cells == null || excelLine.Cells.Count < 1)
                {
                    data.Add(lineContent);
                    break;
                }

                int cellindex = 0;

                foreach (Range cell in excelLine.Cells)
                {
                    cellindex++;

                    if (cell.Value2 == null)
                    {
                        lineContent.Add(string.Empty);
                        Console.WriteLine(string.Empty);
                    }
                    else
                    {
                        // check for DateTime Column
                        if (dateTimeColumns.Contains(cellindex.ToString()))
                        {
                            try
                            {
                                double   oleDate   = Double.Parse(cell.Value2.ToString());
                                DateTime converted = DateTime.FromOADate(oleDate);
                                lineContent.Add(converted.ToShortDateString());
                            }
                            catch (Exception)
                            {
                                // Formatting Error
                                lineContent.Add(string.Empty);
                            }
                        }
                        else // simple string cell
                        {
                            lineContent.Add((cell.Value2.ToString()).Trim());
                            Console.WriteLine((cell.Value2.ToString()).Trim());
                        }
                    }
                }

                data.Add(lineContent);

                if (ignoreHeader && i == 2)
                {
                    // reset container to delete headerline
                    data = new List <List <string> >();
                }

                // check eof
                if (lineContent.Count == lineContent.Count(emptyline => emptyline == string.Empty))
                {
                    ZaehlerLeerZeilen = ZaehlerLeerZeilen + 1;
                    if (ZaehlerLeerZeilen >= IgnoreEmptyRows)
                    {
                        break;
                    }
                }
                else
                {
                    ZaehlerLeerZeilen = 0;
                }
            }

            xlsApp.DisplayAlerts = false;

            xlsApp.Quit();

            System.Threading.Thread.CurrentThread.CurrentCulture = systemCultureInfo;

            return(data);
        }
示例#12
0
        /// <summary>The main method that gets called on application startup.</summary>
        /// <param name="args">
        ///  <para>Array of command line arguments provided to this application.</para>
        ///  <para>The first argument will be the path to this application's executable.</para>
        ///  <para>
        ///   The second argument is expected to be a path to the XML file providing this application settings
        ///   to build the project template.
        ///  </para>
        /// </param>
        private static void Main(string[] args)
        {
            // Do not continue if an argument was not provided.
            if ((args.Length < 1) || string.IsNullOrEmpty(args[0]))
            {
                System.Console.WriteLine("Usage: VisualStudio.ProjectTemplate.Builder <PathToXmlSettingsFile>");
                return;
            }

            // Fetch the path to the XML file which provides the settings this builder needs to create the project template.
            string settingsFilePath = args[0];

            if (System.IO.File.Exists(settingsFilePath) == false)
            {
                System.Console.WriteLine("File not found: " + settingsFilePath);
                System.Environment.ExitCode = -1;
                return;
            }

            // Set this application's current directory to where the XML file resides.
            // This allows the XML file to use relative paths to its project files.
            string settingsDirectoryPath = System.IO.Path.GetDirectoryName(settingsFilePath);

            if (string.IsNullOrEmpty(settingsDirectoryPath) == false)
            {
                System.Environment.CurrentDirectory = settingsDirectoryPath;
            }

            // Load the given XML file.
            System.Xml.XmlNode builderXmlNode = null;
            try
            {
                var xmlDocument = new System.Xml.XmlDocument();
                xmlDocument.Load(settingsFilePath);
                foreach (System.Xml.XmlNode nextXmlNode in xmlDocument.ChildNodes)
                {
                    if (nextXmlNode.Name == "VSProjectTemplateBuilder")
                    {
                        builderXmlNode = nextXmlNode;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (builderXmlNode.Name == null)
            {
                System.Console.WriteLine("The given XML file must contain a 'VSProjectTemplateBuilder' node at its root.");
                System.Environment.ExitCode = -1;
                return;
            }

            // Fetch the "VSTemplate" node from the XML file.
            System.Xml.XmlNode vsTemplateXmlNode = null;
            foreach (System.Xml.XmlNode nextXmlNode in builderXmlNode.ChildNodes)
            {
                if (nextXmlNode.Name == "VSTemplate")
                {
                    vsTemplateXmlNode = nextXmlNode;
                    break;
                }
            }
            if (vsTemplateXmlNode == null)
            {
                System.Console.WriteLine(string.Format("XML file '{0}' is missing a 'VSTemplate' node.", settingsFilePath));
                System.Environment.ExitCode = -1;
                return;
            }

            // Fetch the "VSTemplate\TemplateContent\Project" node and its project file path from the XML file.
            System.Xml.XmlNode projectXmlNode  = null;
            string             projectFilePath = null;

            foreach (System.Xml.XmlNode outerXmlNode in vsTemplateXmlNode.ChildNodes)
            {
                if (outerXmlNode.Name == "TemplateContent")
                {
                    foreach (System.Xml.XmlNode innerXmlNode in outerXmlNode.ChildNodes)
                    {
                        if (innerXmlNode.Name == "Project")
                        {
                            projectXmlNode = innerXmlNode;
                            var attributeNode = innerXmlNode.Attributes.GetNamedItem("File");
                            if (attributeNode != null)
                            {
                                projectFilePath = attributeNode.Value;
                            }
                            break;
                        }
                    }
                    break;
                }
            }
            if (string.IsNullOrEmpty(projectFilePath))
            {
                string message =
                    "XML file '" + settingsFilePath +
                    "' does not provide a source project file path to turn into a template.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (System.IO.File.Exists(projectFilePath) == false)
            {
                string message =
                    "Project file '" + projectFilePath + "' referenced in XML file '" +
                    settingsFilePath + "' was not found.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Do not continue if the given Visual Studio project file is not supported by this application.
            // This application only supports C# and VB.NET project files.
            var projectFileExtensionName = System.IO.Path.GetExtension(projectFilePath);

            if (string.IsNullOrEmpty(projectFileExtensionName))
            {
                projectFileExtensionName = string.Empty;
            }
            projectFileExtensionName = projectFileExtensionName.ToLower();
            if (sSupportedProjectExtensions.Contains(projectFileExtensionName) == false)
            {
                string message =
                    "Project file '" + projectFilePath + "' is not supported by this project template builder." +
                    System.Environment.NewLine +
                    "This builder only supports C# and VB.NET projects.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Extract the project file's directory path.
            var projectDirectoryPath = System.IO.Path.GetDirectoryName(projectFilePath);

            if (string.IsNullOrEmpty(projectDirectoryPath))
            {
                projectDirectoryPath = System.IO.Directory.GetCurrentDirectory();
            }

            // Fetch the root namespace name from the project file.
            // This will be used a the template name and string replace it in all project files later.
            sProjectNamespaceName = FetchProjectRootNamespaceFrom(projectFilePath);
            if (string.IsNullOrEmpty(sProjectNamespaceName))
            {
                System.Console.WriteLine("Failed to find 'RootNamespace' element in project file '" + projectFilePath + "'.");
                System.Environment.ExitCode = -1;
                return;
            }

            // Extract the output settings from the given XML file.
            OutputSettings outputSettings = null;

            foreach (System.Xml.XmlNode nextXmlNode in builderXmlNode.ChildNodes)
            {
                if (nextXmlNode.Name == "Output")
                {
                    outputSettings = OutputSettings.From(nextXmlNode);
                    break;
                }
            }
            if (outputSettings == null)
            {
                string message = "XML file '" + settingsFilePath + "' is missing an 'Output' node.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (outputSettings.IntermediateFolderPath.Length <= 0)
            {
                string message = "XML file '" + settingsFilePath + "' must provide an 'IntermediateFolderPath'.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (outputSettings.FolderPaths.Count <= 0)
            {
                string message = "XML file '" + settingsFilePath + "' must provide at least 1 output folder path.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // If an output file name was not provided, then use the project file's name.
            if (outputSettings.FileName.Length <= 0)
            {
                outputSettings.FileName = System.IO.Path.GetFileNameWithoutExtension(projectFilePath) + ".zip";
            }

            // Create and clean the intermedate directory.
            outputSettings.IntermediateFolderPath =
                System.IO.Path.Combine(outputSettings.IntermediateFolderPath,
                                       System.IO.Path.GetFileNameWithoutExtension(outputSettings.FileName));
            try
            {
                if (System.IO.Directory.Exists(outputSettings.IntermediateFolderPath))
                {
                    bool isRecursiveDelete = true;
                    System.IO.Directory.Delete(outputSettings.IntermediateFolderPath, isRecursiveDelete);
                }
                System.IO.Directory.CreateDirectory(outputSettings.IntermediateFolderPath);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Traverse the XML project node, update its XML settings, and copy the project's files.
            try
            {
                foreach (System.Xml.XmlNode vsTemplateChildXmlNode in vsTemplateXmlNode.ChildNodes)
                {
                    if (vsTemplateChildXmlNode.Name == "TemplateData")
                    {
                        foreach (System.Xml.XmlNode templateDataChildXmlNode in vsTemplateChildXmlNode.ChildNodes)
                        {
                            if ((templateDataChildXmlNode.Name == "Icon") ||
                                (templateDataChildXmlNode.Name == "PreviewImage"))
                            {
                                // Fetch the image file path and verify the file actually exists.
                                string sourceImageFilePath = templateDataChildXmlNode.InnerText;
                                if (System.IO.File.Exists(sourceImageFilePath) == false)
                                {
                                    System.Console.WriteLine(string.Format(
                                                                 "'{0}' file '{1}' not found.",
                                                                 templateDataChildXmlNode.Name, sourceImageFilePath));
                                    System.Environment.ExitCode = -1;
                                    return;
                                }

                                // Copy the file to the template's intermediate directory.
                                string targetImageFileName = "__" + System.IO.Path.GetFileName(sourceImageFilePath);
                                string targetImageFilePath = System.IO.Path.Combine(
                                    outputSettings.IntermediateFolderPath, targetImageFileName);
                                System.IO.File.Copy(sourceImageFilePath, targetImageFilePath);

                                // Update the XML's image file path, to be used by the final template file.
                                templateDataChildXmlNode.InnerText = targetImageFileName;
                            }
                        }
                    }
                    else if (vsTemplateChildXmlNode.Name == "TemplateContent")
                    {
                        foreach (System.Xml.XmlNode templateContentChildXmlNode in vsTemplateChildXmlNode.ChildNodes)
                        {
                            if (templateContentChildXmlNode.Name == "Project")
                            {
                                // Replace the "Project" element's "File" attribute with a path to the template's project file.
                                var attribute = templateContentChildXmlNode.Attributes.GetNamedItem("File");
                                if (attribute != null)
                                {
                                    attribute.InnerText = System.IO.Path.GetFileName(projectFilePath);
                                }

                                // Remove all of the "Project" node's children, if any.
                                templateContentChildXmlNode.InnerXml = string.Empty;

                                // Copy all of the project's relevant files to a temporary template directory.
                                // This also replaces project names, namespaces, and GUIDs with template variables.
                                CopyProjectDirectoryFiles(
                                    templateContentChildXmlNode, projectDirectoryPath,
                                    outputSettings.IntermediateFolderPath);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Create the *.vstemplate file using the updated "vsTemplateXmlNode" up above.
            try
            {
                string vsTemplateFilePath    = System.IO.Path.Combine(outputSettings.IntermediateFolderPath, "MyTemplate.vstemplate");
                var    vsTemplateXmlDocument = new System.Xml.XmlDocument();
                vsTemplateXmlDocument.AppendChild(vsTemplateXmlDocument.ImportNode(vsTemplateXmlNode, true));
                vsTemplateXmlDocument.Save(vsTemplateFilePath);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Failed to create *.vstemplate file. Reason:");
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Zip up the project template folder.
            string intermediateZipFilePath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(outputSettings.IntermediateFolderPath), outputSettings.FileName);

            try
            {
                if (System.IO.File.Exists(intermediateZipFilePath))
                {
                    System.IO.File.Delete(intermediateZipFilePath);
                }
                bool isZippingBaseDirectory = false;
                System.IO.Compression.ZipFile.CreateFromDirectory(
                    outputSettings.IntermediateFolderPath, intermediateZipFilePath,
                    System.IO.Compression.CompressionLevel.NoCompression, isZippingBaseDirectory);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(
                    "Failed to create '" + intermediateZipFilePath + "' project template zip file. Reason:");
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Copy the zipped up project template to the given destination(s).
            try
            {
                foreach (string directoryPath in outputSettings.FolderPaths)
                {
                    if (System.IO.Directory.Exists(directoryPath) == false)
                    {
                        System.IO.Directory.CreateDirectory(directoryPath);
                    }
                    string outputFilePath = System.IO.Path.Combine(directoryPath, outputSettings.FileName);
                    System.IO.File.Copy(intermediateZipFilePath, outputFilePath, true);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }
        }
        /// <summary>
        /// 从PDM数据结构定义XML文件中加载数据结构信息
        /// </summary>
        /// <param name="doc">XML文档对象</param>
        /// <returns>加载的字段信息个数</returns>
        public int LoadFromPDMXMLDocument(XmlDocument doc)
        {
            intFillStyle = FillStyleConst.PDM;
            int RecordCount = 0;

            myTables.Clear();
            XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable);

            nsm.AddNamespace("a", "attribute");
            nsm.AddNamespace("c", "collection");
            nsm.AddNamespace("o", "object");
            XmlNode RootNode = doc.SelectSingleNode("/Model/o:RootObject/c:Children/o:Model", nsm);

            if (RootNode == null)
            {
                return(0);
            }
            strName        = ReadXMLValue(RootNode, "a:Name", nsm);
            strDescription = strName;
            // 数据表
            foreach (XmlNode TableNode in RootNode.SelectNodes("c:Tables/o:Table", nsm))
            {
                TableInfo table = new TableInfo();
                myTables.Add(table);
                table.Name   = ReadXMLValue(TableNode, "a:Code", nsm);
                table.Remark = ReadXMLValue(TableNode, "a:Name", nsm);
                string keyid = ReadXMLValue(TableNode, "c:PrimaryKey/o:Key/@Ref", nsm);
                System.Collections.Specialized.StringCollection Keys =
                    new System.Collections.Specialized.StringCollection();
                if (keyid != null)
                {
                    foreach (XmlNode KeyNode in TableNode.SelectNodes(
                                 "c:Keys/o:Key[@Id = '" + keyid + "']/c:Key.Columns/o:Column/@Ref", nsm))
                    {
                        Keys.Add(KeyNode.Value);
                    }
                }
                foreach (XmlNode FieldNode in TableNode.SelectNodes("c:Columns/o:Column", nsm))
                {
                    RecordCount++;
                    string    id    = ((XmlElement)FieldNode).GetAttribute("Id");
                    FieldInfo field = new FieldInfo();
                    table.Fields.Add(field);
                    field.Name        = ReadXMLValue(FieldNode, "a:Code", nsm);
                    field.Remark      = ReadXMLValue(FieldNode, "a:Name", nsm);
                    field.Description = ReadXMLValue(FieldNode, "a:Comment", nsm);
                    string FieldType = ReadXMLValue(FieldNode, "a:DataType", nsm);
                    if (FieldType != null)
                    {
                        int index = FieldType.IndexOf("(");
                        if (index > 0)
                        {
                            FieldType = FieldType.Substring(0, index);
                        }
                    }
                    field.FieldType = FieldType;

                    field.FieldWidth = ReadXMLValue(FieldNode, "a:Length", nsm);
                    if (Keys.Contains(id))
                    {
                        field.PrimaryKey = true;
                    }
                }
            }
            return(RecordCount);
        }
示例#14
0
        /// <summary>
        /// Performs a complete counting and summation of all lines
        /// in all projects and files.
        /// </summary>
        private void SumSolution()
        {
            try
            {
                // Clean the list
                lvSummary.Items.Clear();
                lvFileList.Items.Clear();
                lvFileList.Groups.Clear();

                // Configure progress bars
                tsprgTotal.Minimum = 0;
                tsprgTotal.Step    = 1;
                tsprgTask.Minimum  = 0;
                tsprgTask.Step     = 1;

                // Skip if there are no projects
                if (m_summaryList == null || (m_summaryList != null && m_summaryList.Count == 1))
                {
                    MessageBox.Show("There are no projects loaded to summarize.", "Line Counter");
                    return;
                }

                // Get all projects summary
                LineCountSummary allProjects = m_summaryList[0];
                allProjects.LineCountSummaryDetails.Reset();
                AddSummaryListItem(allProjects, lvSummary.Groups["lvgAllProj"]);

                tsprgTotal.Maximum = m_summaryList.Count;
                tsprgTotal.Value   = 0;
                for (int s = 1; s < m_summaryList.Count; s++)
                {
                    tsprgTotal.PerformStep();

                    LineCountSummary summary = m_summaryList[s];
                    summary.LineCountSummaryDetails.Reset();
                    AddSummaryListItem(summary, lvSummary.Groups["lvgEachProj"]);

                    tsprgTask.Maximum = summary.FileLineCountInfo.Count;
                    tsprgTask.Value   = 0;
                    for (int i = 0; i < summary.FileLineCountInfo.Count; i++)
                    {
                        tsprgTask.PerformStep();

                        LineCountInfo info = summary.FileLineCountInfo[i];
                        if (m_countableTypes.Contains(info.FileType))
                        {
                            info.LineCountInfoDetails.Reset();
                                                        #if IMPR2
                            foreach (CountingAlgorithmDescriptor desc in countingAlgorithms)
                            {
                                if (desc.CanCountLines(info))
                                {
                                    desc.GetAlgorithm().CountLines(info);
                                    break;
                                }
                            }
                                                        #else
                            try
                            {
                                CountLines counter = m_countAlgorithms[info.FileType];
                                counter(info);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                Console.WriteLine(ex.StackTrace);
                            }
                                                        #endif
                            info.LineCountInfoDetails.Summarize();

                            allProjects.LineCountSummaryDetails.Add(info.LineCountInfoDetails);
                            summary.LineCountSummaryDetails.Add(info.LineCountInfoDetails);

                            tstxtLinesCounted.Text = allProjects.LineCountSummaryDetails.TotalLines.ToString();

                            AddFileListItem(info);
                        }
                    }

                    summary.LineCountSummaryDetails.Summarize();
                    LineCountDetails details = summary.LineCountSummaryDetails;
                    summary.LinkedListViewItem.SubItems[1].Text = details.TotalLines.ToString();
                    summary.LinkedListViewItem.SubItems[2].Text = details.CodeLines.ToString();
                    summary.LinkedListViewItem.SubItems[3].Text = details.CommentLines.ToString();
                    summary.LinkedListViewItem.SubItems[4].Text = details.BlankLines.ToString();
                    summary.LinkedListViewItem.SubItems[5].Text = details.NetLines.ToString();
                    details = null;
                }

                allProjects.LineCountSummaryDetails.Summarize();
                LineCountDetails totals = allProjects.LineCountSummaryDetails;
                allProjects.LinkedListViewItem.SubItems[1].Text = totals.TotalLines.ToString();
                allProjects.LinkedListViewItem.SubItems[2].Text = totals.CodeLines.ToString();
                allProjects.LinkedListViewItem.SubItems[3].Text = totals.CommentLines.ToString();
                allProjects.LinkedListViewItem.SubItems[4].Text = totals.BlankLines.ToString();
                allProjects.LinkedListViewItem.SubItems[5].Text = totals.NetLines.ToString();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }

            tsprgTotal.Value = tsprgTotal.Maximum;
        }
示例#15
0
        public void Remove(System.Collections.Specialized.StringCollection Identifiers)
        {
            ArrayList memList = new ArrayList();

            for (int i = 0; i < Identifiers.Count; i++)
            {
                short axisOrdinal = -1;
                int   pos         = -1;
                int   mpos        = -1;
                this.CellsetPositionFromIdentifier(Identifiers[i], ref axisOrdinal, ref pos, ref mpos);

                CellsetMember cstMem = _report.Cellset.GetCellsetMember((byte)axisOrdinal, mpos, pos);
                memList.Add(cstMem);
            }

            // remove members
            System.Collections.Specialized.StringCollection parentList = new System.Collections.Specialized.StringCollection();
            for (int i = 0; i < memList.Count; i++)
            {
                CellsetMember cstMem = (CellsetMember)memList[i];
                Hierarchy     hier   = _report.Schema.GetHierarchyFromMemberUniqueName(cstMem.UniqueName);

                // get member, remove if exisits
                DataMember dmem = (DataMember)hier.GetMember(cstMem.UniqueName);
                if (dmem != null)
                {
                    dmem.Hierarchy.RemoveMember(dmem);
                    continue;
                }

                // if not found by unique name, check if member was part of MemberChildrenSet (autoselect),
                // in this case we convert it to not-autoselect
                if (cstMem.LevelDepth == 0)
                {
                    continue;
                }
                SchemaMember parentMem = _report.Schema.GetMemberParent(hier, cstMem.UniqueName);
                if (parentMem != null)
                {
                    if (parentList.Contains(parentMem.UniqueName))
                    {
                        continue;                         // parent already handled
                    }
                    parentList.Add(parentMem.UniqueName);
                    MemberChildrenSet mcs = hier.CalculatedMembers.GetMemberChildrenSet(parentMem.UniqueName);
                    if (mcs != null)
                    {
                        // add children
                        hier.RemoveMember(mcs);
                        hier.AddMemberChildren(parentMem.UniqueName, false);
                    }
                }
            }

            // finally remove members
            for (int i = 0; i < memList.Count; i++)
            {
                CellsetMember cstMem = (CellsetMember)memList[i];
                Hierarchy     hier   = _report.Schema.GetHierarchyFromMemberUniqueName(cstMem.UniqueName);

                hier.DataMembers.Remove(cstMem.UniqueName);
            }
        }
示例#16
0
        protected void localization_FK_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<CountryLanguageDto> localizations = (List<CountryLanguageDto>)ViewState["countries"];
            DataTable page_tags = (DataTable)ViewState["page_tags"];
            CountryLanguageDto foundLocalization = localizations.Find(l => l.LocalizationId == int.Parse(localization_FK.SelectedItem.Value));


            if (foundLocalization != null)
            {
                DataView dv;
                System.Collections.Specialized.StringCollection regions = new System.Collections.Specialized.StringCollection();
                regions.Add("Americas");
                regions.Add("EMEA");

                string region = foundLocalization.WebPageInRegion;

                if (!(regions.Contains(hidden_region.Text) && regions.Contains(region)) && hidden_region.Text != region)
                {
                    //only rebind dd's if region is different from region before

                    if (region == "APJ")
                    {
                        //sPropSalesCycleLabel.Text = "Marketing Funnel:";
                        //apj_01.Visible = false;

                        //dv = new DataView(page_tags, "(tag_group = 's_prop1__sales_cycle' AND (region_applicability = 'APJ' OR region_applicability IS NULL)) OR tag_id = -1", "ordering", DataViewRowState.CurrentRows);
                        //dd_omni_prop1.DataSource = (ICollection)dv;
                        //dd_omni_prop1.DataTextField = "tag_value";
                        //dd_omni_prop1.DataValueField = "tag_id";

                        //dd_omni_prop1.DataBind();

                        dv = new DataView(page_tags, "(tag_group = 's_prop16__bu_tag' AND (region_applicability = 'APJ' OR region_applicability IS NULL)) OR tag_id = -1", "ordering", DataViewRowState.CurrentRows);
                        dd_omni_prop16.DataSource = (ICollection)dv;
                        dd_omni_prop16.DataTextField = "tag_value";
                        dd_omni_prop16.DataValueField = "tag_id";

                        dd_omni_prop16.DataBind();
                    }
                    else
                    {
                        //webpage_in_region =  "EMEA" or "Americas"
                        //sPropSalesCycleLabel.Text = "Sales Cycle:";
                        //apj_01.Visible = true;

                        //dv = new DataView(page_tags, "(tag_group = 's_prop1__sales_cycle' AND (region_applicability = 'EMEA' OR region_applicability IS NULL)) OR tag_id = -1", "ordering", DataViewRowState.CurrentRows);
                        //dd_omni_prop1.DataSource = (ICollection)dv;
                        //dd_omni_prop1.DataTextField = "tag_value";
                        //dd_omni_prop1.DataValueField = "tag_id";

                        //dd_omni_prop1.DataBind();

                        dv = new DataView(page_tags, "(tag_group = 's_prop16__bu_tag' AND (region_applicability = 'EMEA' OR region_applicability IS NULL)) OR tag_id = -1", "ordering", DataViewRowState.CurrentRows);
                        dd_omni_prop16.DataSource = (ICollection)dv;
                        dd_omni_prop16.DataTextField = "tag_value";
                        dd_omni_prop16.DataValueField = "tag_id";

                        dd_omni_prop16.DataBind();
                    }
                }

                hidden_region.Text = region;

            }
        }
示例#17
0
        public async Task modpacksUpdate()
        {
            modpacksListContainer.Children.Clear();
            var dirlist = Directory.GetDirectories(config.M_F_P + "Packs\\");

            if (dirlist.Count() != 0)
            {
                foreach (var dir in dirlist)
                {
                    string modpackversion;
                    string modpackname;
                    string mcversion;
                    try
                    {
                        var     json = System.IO.File.ReadAllText(dir + "\\" + new DirectoryInfo(dir).Name + ".json");
                        dynamic jObj = JsonConvert.DeserializeObject(json);
                        modpackname    = jObj.modpackName;
                        modpackversion = jObj.modpackVersion;
                        mcversion      = jObj.mc_version;
                    }
                    catch (FileNotFoundException ex)
                    {
                        continue;
                    }
                    var card = new MaterialDesignThemes.Wpf.Card();
                    card.Name = "card" + new DirectoryInfo(dir.Replace(" ", "")).Name;
                    try
                    {
                        modpacksListContainer.RegisterName(card.Name, card);
                    }
                    catch
                    {
                        modpacksListContainer.UnregisterName(card.Name);
                        modpacksListContainer.RegisterName(card.Name, card);
                    }
                    card.Height = 200;
                    card.Width  = 620;
                    card.Margin = new Thickness(10);
                    card.HorizontalAlignment = HorizontalAlignment.Left;
                    var insiderStackPanel = new StackPanel();
                    insiderStackPanel.Orientation = Orientation.Horizontal;

                    card.Content = insiderStackPanel;
                    //INSIDE STACKPANEL

                    Style buttonstyle = Application.Current.FindResource("MaterialDesignFloatingActionMiniAccentButton") as Style;

                    var bookmarkbutton   = new Button();
                    var iconpackbookmark = new MaterialDesignThemes.Wpf.PackIcon();
                    System.Collections.Specialized.StringCollection x = (System.Collections.Specialized.StringCollection)Properties.Settings.Default["bookmarks"];
                    if (x.Contains(dir))
                    {
                        iconpackbookmark.Kind  = MaterialDesignThemes.Wpf.PackIconKind.BookmarkCheck;
                        bookmarkbutton.ToolTip = "This modpack is bookmarked";
                    }
                    else
                    {
                        iconpackbookmark.Kind  = MaterialDesignThemes.Wpf.PackIconKind.Bookmark;
                        bookmarkbutton.ToolTip = "This modpack is not bookmarked";
                    }
                    bookmarkbutton.Content             = iconpackbookmark;
                    bookmarkbutton.Style               = buttonstyle;
                    bookmarkbutton.HorizontalAlignment = HorizontalAlignment.Right;
                    bookmarkbutton.VerticalAlignment   = VerticalAlignment.Bottom;
                    bookmarkbutton.Margin              = new Thickness(0, 0, -35, 0);
                    Panel.SetZIndex(bookmarkbutton, 10);
                    bookmarkbutton.Click += new RoutedEventHandler((sender, e) => bookmark_click(this, e, card.Name, dir, bookmarkbutton));

                    var cloudbutton   = new Button();
                    var iconpackcloud = new MaterialDesignThemes.Wpf.PackIcon();
                    iconpackcloud.Kind              = MaterialDesignThemes.Wpf.PackIconKind.Cloud;
                    cloudbutton.ToolTip             = "Cloud Syncing Service";
                    cloudbutton.Content             = iconpackcloud;
                    cloudbutton.Style               = buttonstyle;
                    cloudbutton.HorizontalAlignment = HorizontalAlignment.Right;
                    cloudbutton.VerticalAlignment   = VerticalAlignment.Bottom;
                    cloudbutton.Margin              = new Thickness(0, 0, -80, 0);
                    Panel.SetZIndex(cloudbutton, 10);
                    cloudbutton.Click += new RoutedEventHandler((sender, e) => cloud_click(this, e, card.Name, dir));

                    var image = new Image();
                    image.Source  = new BitmapImage(new Uri(@"/Images/modpacks.jpg", UriKind.Relative));
                    image.Stretch = Stretch.Fill;
                    image.Width   = 300;
                    image.Height  = 120;

                    var datastackpanel = new StackPanel();
                    datastackpanel.Width = 290;

                    insiderStackPanel.Children.Add(bookmarkbutton);
                    insiderStackPanel.Children.Add(cloudbutton);
                    insiderStackPanel.Children.Add(image);
                    insiderStackPanel.Children.Add(datastackpanel);

                    var title = new Label();
                    title.FontSize            = 15;
                    title.FontWeight          = FontWeights.ExtraBold;
                    title.HorizontalAlignment = HorizontalAlignment.Center;
                    title.Content             = new DirectoryInfo(dir).Name;
                    datastackpanel.Children.Add(title);

                    var modpackName = new Label();
                    modpackName.Content = "Modpack Name: " + modpackname;
                    datastackpanel.Children.Add(modpackName);

                    var modpackVersion = new Label();
                    modpackVersion.Content = "Modpack Version: " + modpackversion;
                    datastackpanel.Children.Add(modpackVersion);

                    var minecraftversion = new Label();
                    minecraftversion.Content = "MC Version: " + mcversion;
                    datastackpanel.Children.Add(minecraftversion);


                    var buttonStackPanel = new StackPanel();
                    buttonStackPanel.Orientation         = Orientation.Horizontal;
                    buttonStackPanel.HorizontalAlignment = HorizontalAlignment.Center;
                    datastackpanel.Children.Add(buttonStackPanel);

                    var playbutton = new Button();
                    playbutton.Content    = "Play";
                    playbutton.Foreground = new SolidColorBrush(Colors.White);
                    playbutton.Margin     = new Thickness(20, 30, 3, 0);
                    playbutton.Click     += new RoutedEventHandler((sender, e) => play_click(this, e, card.Name, dir));

                    var deletebutton = new Button();
                    deletebutton.Content    = "Delete";
                    deletebutton.Foreground = new SolidColorBrush(Colors.White);
                    deletebutton.Margin     = new Thickness(3, 30, 0, 0);
                    deletebutton.Click     += new RoutedEventHandler((sender, e) => delete_click(this, e, card.Name, dir));

                    buttonStackPanel.Children.Add(playbutton);
                    buttonStackPanel.Children.Add(deletebutton);

                    modpacksListContainer.Children.Add(card);
                }
            }
            else
            {
                var label = new Label();
                label.Name     = "nomodpacks";
                label.Content  = "No installed modpack";
                label.FontSize = 30;
                modpacksListContainer.Children.Add(label);
            }
        }
示例#18
0
                /// -----------------------------------------------------------------------------
                /// <summary>
                /// Will load all modules in given list
                /// </summary>
                /// <param name="ModFiles"></param>
                /// <remarks>
                /// Once a module is loaded it will be added the the Module list,
                /// and will then have ModLoad called and the filename property set
                /// </remarks>
                /// <history>
                /// 	[Caleb]	6/18/2005	Created
                /// </history>
                /// -----------------------------------------------------------------------------
                public void LoadModules(string[] ModFiles)
                {
                    System.Collections.Specialized.StringCollection ModuleFiles = new System.Collections.Specialized.StringCollection();
                    Assembly tObject;
                    //File tFile;
                    int tIndex;
                    short tCount = 0;
                    string tMod;
                    string tString;
                    System.Collections.Specialized.StringCollection tFound = new System.Collections.Specialized.StringCollection();
                    foreach (string xMod in ModFiles)
                    {
                        ModuleFiles.Add(xMod);
                    }
                    BlackLightModule tModule;
                    //Cycle through the modules untill they are all loaded or removed
                    while (ModuleFiles.Count > 0)
                    {
                        try
                        {
                            //Infinate loop check
                            if (tCount > 1000)
                            {
                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "It appears we have gotten into an infinate loop while loading modules, loading halted", "Most likely cause is two or more modules require each other and will never be able to load", "", "");
                                return;
                            }
                            tCount += Convert.ToInt16(1);

                            //Get the filename
                            tMod = ModuleFiles[0].ToString();

                            //Make sure it exists
                            if (File.Exists("modules/" + tMod))
                            {

                                //Use .NET to attempt to load the class inside the dll
                                tObject = @Assembly.LoadFrom("modules/" + tMod);

                                //Make sure everything is still hawt or remove the failed module
                                if (tObject == null)
                                {
                                    ModuleFiles.RemoveAt(0);
                                }

                                //Get a list of the classes the module contains
                                Type[] tList = tObject.GetTypes();
                                //Cycle through them all
                                foreach (Type tType in tList)
                                {

                                    //Make sure it uses our module base somewhere
                                    if (tType.IsSubclassOf(typeof(BlackLightModule)) == true)
                                    {
                                        //Alrighty it's a valid module now what?

                                        //Well lets check if its a special module, currently only datadrivers

                                        //Ooooo isn't this sexy
                                        tModule = ((BlackLightModule) tType.GetConstructor(new Type[] { typeof(ServicesDaemon) }).Invoke(new object[] {Base}));

                                        //Or not :'(
                                        if (tModule == null)
                                        {
                                            ModuleFiles.RemoveAt(0);
                                        }

                                        if (tType.IsSubclassOf(typeof(DB.DataDriver)) == true)
                                        {
                                            if (DataDriver == "")
                                            {
                                                DataDriver = tModule.Name;
                                            }
                                            else
                                            {
                                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "DataBase driver already loaded!", "File does not exist", "", "");
                                                ModuleFiles.RemoveAt(0);
                                            }
                                        }

                                        //Set the internal filename for the ModuleList Class
                                        tModule.FileName = tMod;

                                        //Clear the list of found modules for requirements
                                        tFound.Clear();

                                        //Malicious module coder?
                                        if (tModule.Requires.Count < 1000)
                                        {

                                            //Check if they actually have any requirements (Hope they don't)
                                            if (tModule.Requires.Count > 0)
                                            {
                                                //What kind of peice of shit coder requires other modules...oh right chanserv needs
                                                //nickserv

                                                //Check if its loaded already and work is saved
                                                foreach (string xString in tModule.Requires)
                                                {
                                                    tString = xString.ToLower();
                                                    //Make sure the dumbass didn't require themselves
                                                    if (tMod.ToLower() != tString)
                                                    {

                                                        //Make sure we havn't already found it
                                                        if (tFound.Contains(tString) == false)
                                                        {

                                                            //Now check if its loaded
                                                            if (Modules.Contains(tString) == false)
                                                            {
                                                                //Nope not loaded, does the file actually exist?
                                                                if (File.Exists("modules/" + tMod) == false)
                                                                {
                                                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Requirements for " + tMod + " not met", "File does not exist", "", "");
                                                                    ModuleFiles.RemoveAt(0);
                                                                    break;
                                                                }
                                                                else
                                                                {
                                                                    //It does, heh, so the module still could be loaded

                                                                    //Well maybe, lets see if its possible
                                                                    if (ModuleFiles.Contains(tString) == false)
                                                                    {
                                                                        //Nope? Well thats the end of that module
                                                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Requirements for " + tMod + " not met", "Requirement not found in avalability list", "", "");
                                                                        ModuleFiles.RemoveAt(0);
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                //Alrighty then, so the module has already been loaded, add it to the found list
                                                                tFound.Add(tString);
                                                                // Base.Service.SendLogMessage("ModuleManagement", "LoadModules", Errors.LOG_DEBUG_AND_WARNING, "Found", "", "", "")
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //One word: Dumbass
                                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "A module cannot require itself", "", "", "");
                                                        ModuleFiles.RemoveAt(0);
                                                        break;
                                                    }
                                                }

                                                //Make sure we didn't remove our module already
                                                if (ModuleFiles.Contains(tMod))
                                                {

                                                    //Check if all the requirements are met
                                                    if (tFound.Count == tModule.Requires.Count)
                                                    {

                                                        //Verify its not already loaded
                                                        if (Modules.Contains(tMod) == false && Modules.Contains(tModule.Name) == false)
                                                        {
                                                            //Add it
                                                            Modules.Add(tModule);
                                                            // tModule.ModLoad()
                                                        }
                                                        else
                                                        {
                                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module with duplicate name already loaded: " + tMod, "", "", "");
                                                        }
                                                        //Remove it and goto the next module
                                                        ModuleFiles.RemoveAt(0);
                                                    }
                                                    else
                                                    {
                                                        //The requirements are not met, so we
                                                        //Send it to the back?
                                                        ModuleFiles.RemoveAt(0);
                                                        ModuleFiles.Add(tMod);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                //YAY! No requirements. Now just make sure its not already loaded and add it to the list
                                                if (Modules.Contains(tMod) == false && Modules.Contains(tModule.Name) == false)
                                                {
                                                    Modules.Add(tModule);
                                                    // tModule.ModLoad()
                                                }
                                                else
                                                {
                                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module with duplicate name already loaded: " + tMod, "", "", "");
                                                }
                                                ModuleFiles.RemoveAt(0);
                                            }
                                        }
                                        else
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module contains to many requirements: " + tMod, "", "", "");
                                        }
                                    }
                                }

                            }
                            else
                            {
                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "File does not exist: " + tMod, "", "", "");
                                ModuleFiles.RemoveAt(0);
                            }
                        }
                        catch (Exception e)
                        {
                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Exception", "", e.Message, e.StackTrace);
                            //MessageBox.Show(e.Message + " " + e.StackTrace);
                        }
                    }
                    //Now give our user a nice pretty list of which modules f****d up
                    for (tIndex = 0; tIndex <= ModFiles.Length - 1; tIndex++)
                    {
                        if (Modules.Contains(ModFiles[tIndex]) == false)
                        {
                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "", "", "");
                        }
                        else
                        {
                            if (Modules[ModFiles[tIndex]].NeedsDBDriver == true)
                            {
                                if (DataDriver == "")
                                {
                                    Modules.Remove(Modules[ModFiles[tIndex]]);
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "No DataDriver Found", "", "");
                                }
                                else
                                {
                                    try
                                    {
                                        if (Modules[ModFiles[tIndex]].ModLoad())
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG, "Loaded Module: " + ModFiles[tIndex].ToString(), "", "", "");
                                        }
                                        else
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", "", "");
                                            RemoveAllRequired(ModFiles[tIndex]);
                                            Modules.Remove(Modules[ModFiles[tIndex]]);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", ex.Message, ex.StackTrace);
                                    }

                                }
                            }
                            else
                            {
                                try
                                    {
                                if (Modules[ModFiles[tIndex]].ModLoad())
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG, "Loaded Module: " + ModFiles[tIndex].ToString(), "", "", "");
                                }
                                else
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", "", "");
                                    RemoveAllRequired(ModFiles[tIndex]);
                                    Modules.Remove(Modules[ModFiles[tIndex]]);
                                }
                                }
                                catch (Exception ex)
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", ex.Message, ex.StackTrace);
                                }
                            }
                        }
                    }
                    //And we are done
                }
示例#19
0
		private void Initializing_pagevariables()
		{
			available_elements = new System.Collections.Specialized.StringCollection();
			available_elements.AddRange(new string[] {"themecolour", "pagetitle", "pagetagline", "mda", "leftnav", "leftnav_page", "introduction", "headline", "required_sentence", "bandedheader", "content", "button", "divider"});
			
			try
			{
				Hashtable h_params = new Hashtable();
						
				page_id_from_session = Session["page_id"].ToString();
				if(Request.QueryString["element"] != null)
				{
					string rqst_element = Request.QueryString["element"].ToString();
					element_to_edit = rqst_element;

					if (!available_elements.Contains(rqst_element))
					{
						Response.Redirect("index.aspx");
					}
				}
				else
				{
					if (Request.QueryString["id"] != null)
					{
						element_id = Request.QueryString["id"].ToString();

						h_params.Add("page_id", page_id_from_session);
						h_params.Add("element_id", element_id);

						element_db = DB.execProc("select_page_variableelements", h_params);

						switch (element_db.Rows[0][1].ToString())
						{
							case "bh": element_to_edit = "bandedheader";
								break;
                            case "di": element_to_edit = "divider";
                                break;
							case "cc": element_to_edit = "content";
								break;
                            case "rh": element_to_edit = "headline";
                                break;
							default: Response.Redirect("index.aspx", true);
								break;
						}
					}
					else
					{
						Response.Redirect("index.aspx", true);
					}
				}

				h_params.Clear();

				h_params = new Hashtable();
				h_params.Add("page_id", page_id_from_session);
				h_params.Add("page_type", "1"); 

				page_type = DB.execProc("select_page_fixedelements", h_params).Rows[0][0].ToString();				

				Session["page_type"] = page_type;
			}
			catch
			{
				Response.Redirect("index.aspx", true);
			}
		}
示例#20
0
        /// <summary>
        /// This is called when the user leaves the datagrid control. At that point,
        /// we check to make sure that:
        /// - All entries have a begin, end, and extension
        /// - That there are no duplicate extensions
        /// - That no entry has an identical begin & end
        /// If there is an error, we report it to the user and put the cursor
        /// on the entry with the issue.
        /// </summary>
        internal void ValidateGrid()
        {
            System.Collections.Specialized.StringCollection allExtensions = new System.Collections.Specialized.StringCollection();
            string extensions, begin, end;
            int    nRow = 0;

            string [] rgExtensions = null;
            char []   splitChars = { ',' };
            string    working;

            dtValues.AcceptChanges();
            foreach (System.Data.DataRow row in dtValues.Rows)
            {
                extensions = (string)row[m_strFileExtensionField];
                begin      = (string)row[m_strBeginCommentField];
                end        = (string)row[m_strEndCommentField];

                // Non-null or single-space extension(s)?
                if ((extensions == null) || (extensions == "") || (extensions == " "))
                {
                    System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidExtension"),
                                                         AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Exclamation);
                    dgEntries.Select(nRow);
                    throw new System.Exception();
                }

                // Non-null or single-space begin comment?
                if ((begin == null) || (begin == "") || (begin == " "))
                {
                    System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidBegin"),
                                                         AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Exclamation);
                    dgEntries.Select(nRow);
                    throw new System.Exception();
                }

                // Non-null or single-space end comment?
                if ((end == null) || (end == "") || (end == " "))
                {
                    System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidEnd"),
                                                         AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Exclamation);
                    dgEntries.Select(nRow);
                    throw new System.Exception();
                }

                // Identical begin & end comments?
                if (begin == end)
                {
                    System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidBeginAndEnd"),
                                                         AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Exclamation);
                    dgEntries.Select(nRow);
                    throw new System.Exception();
                }

                // Validate both that there are extensions there and that they aren't
                // already elsewhere in the datagrid.
                rgExtensions = extensions.Split(splitChars);
                foreach (string extension in rgExtensions)
                {
                    working = extension.Trim().ToUpper();

                    if (working[0] != '.')
                    {
                        System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidExtension"),
                                                             AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.Exclamation);
                        dgEntries.Select(nRow);
                        throw new System.Exception();
                    }

                    if (allExtensions.Contains(working))
                    {
                        System.Windows.Forms.MessageBox.Show(AMResources.GetLocalizedString("ToolsOptionsInvalidExtensionAlreadyExists"),
                                                             AMResources.GetLocalizedString("ToolsOptionsErrorTitle"),
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.Exclamation);
                        dgEntries.Select(nRow);
                        throw new System.Exception();
                    }

                    allExtensions.Add(working);
                }

                nRow++;
            }
        }
示例#21
0
		private void mnuRefreshP4_Click(object sender, System.EventArgs e)
		{
			LoadFileList();

			System.Collections.Specialized.StringCollection opened = new System.Collections.Specialized.StringCollection();
			opened.AddRange(m_p4.GetP4OpenFiles ());

			foreach(ListViewItem item in m_list.Items)
			{
				if(opened.Contains( (string)item.Tag))
				{
					item.ImageIndex = 1;
					item.ForeColor = System.Drawing.Color.Blue;
				}
			}
		}
示例#22
0
        protected void localization_FK_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<CountryLanguageDto> localizations = (List<CountryLanguageDto>)ViewState["countries"];
            List<PageTagDto> pageTags = (List<PageTagDto>)ViewState["page_tags"];

            CountryLanguageDto foundLocalization = localizations.Find(l => l.LocalizationId == int.Parse(localization_FK.SelectedItem.Value));

            if (foundLocalization != null)
            {
                System.Collections.Specialized.StringCollection regions = new System.Collections.Specialized.StringCollection();
                regions.Add("Americas");
                regions.Add("EMEA");

                string region = foundLocalization.WebPageInRegion;

                if (!(regions.Contains(hidden_region.Text) && regions.Contains(region)) && hidden_region.Text != region)
                {
                    //only rebind dd's if region is different from region before

                    if (region == "APJ")
                    {
                        sPropSalesCycleLabel.Text = "Marketing Funnel:";
                        apj_01.Visible = false;

                        List<PageTagDto> listOfOmniProp1 = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("s_prop1__sales_cycle") &&
                            ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("APJ")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                            pt.TagId == -1);
                        listOfOmniProp1.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });
                        dd_omni_prop1.DataSource = listOfOmniProp1;
                        dd_omni_prop1.DataTextField = "DisplayValue";
                        dd_omni_prop1.DataValueField = "TagId";
                        dd_omni_prop1.DataBind();

                        List<PageTagDto> listOfOmniProp16 = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("s_prop16__bu_tag") &&
                            ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("APJ")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                            pt.TagId == -1);
                        listOfOmniProp16.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });
                        dd_omni_prop16.DataSource = listOfOmniProp16;
                        dd_omni_prop16.DataTextField = "DisplayValue";
                        dd_omni_prop16.DataValueField = "TagId";

                        dd_omni_prop16.DataBind();

                        List<PageTagDto> listOfMetaSegment = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("segment") &&
                            ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("APJ")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                            pt.TagId == -1);
                        listOfMetaSegment.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });

                        dd_meta_segment.DataSource = listOfMetaSegment;
                        dd_meta_segment.DataTextField = "DisplayValue";
                        dd_meta_segment.DataValueField = "TagId";

                        dd_meta_segment.DataBind();
                    }
                    else
                    {
                        //webpage_in_region =  "EMEA" or "Americas"
                        sPropSalesCycleLabel.Text = "Sales Cycle:";
                        apj_01.Visible = true;

                        List<PageTagDto> listOfProp1 = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("s_prop1__sales_cycle") &&
                           ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("EMEA")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                           pt.TagId == -1);
                        listOfProp1.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });
                        dd_omni_prop1.DataSource = listOfProp1;
                        dd_omni_prop1.DataTextField = "DisplayValue";
                        dd_omni_prop1.DataValueField = "TagId";
                        dd_omni_prop1.DataBind();

                        List<PageTagDto> listOfProp16 = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("s_prop16__bu_tag") &&
                           ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("EMEA")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                           pt.TagId == -1);
                        listOfProp16.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });
                        dd_omni_prop16.DataSource = listOfProp16;
                        dd_omni_prop16.DataTextField = "DisplayValue";
                        dd_omni_prop16.DataValueField = "TagId";
                        dd_omni_prop16.DataBind();

                        List<PageTagDto> listOfMetaSegment = pageTags.FindAll(pt => (!String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("segment") &&
                          ((!String.IsNullOrEmpty(pt.RegionApplicability) && pt.RegionApplicability.Equals("EMEA")) || String.IsNullOrEmpty(pt.RegionApplicability))) ||
                          pt.TagId == -1);
                        listOfMetaSegment.Sort(delegate(PageTagDto pt1, PageTagDto pt2)
                        {
                            return pt1.Ordering.CompareTo(pt2.Ordering);
                        });
                        dd_meta_segment.DataSource = listOfMetaSegment;
                        dd_meta_segment.DataTextField = "DisplayValue";
                        dd_meta_segment.DataValueField = "TagId";

                        dd_meta_segment.DataBind();
                    }
                }

                hidden_region.Text = region;

            }

        }
        /// <summary>
        /// Updates any locators in the specified File Geodatabase that use the specified Feature Class as Primary Reference Table.  Any Alternate Names Tables that exist for the
        /// specified Feature Class will be copied from the specified Enterprise Geodatabase (InputWorkspace) to the File Geodatabase.
        /// </summary>
        /// <param name="OutputFileGeodatabasePathName">
        /// The Full Path to the Output File Geodatabase that contains the Locators that are to be rebuilt.
        /// </param>
        /// <param name="FeatureClassName">
        /// The Name of the Feature Class that has been updated in the Output File Geodatabase.
        /// </param>
        /// <param name="InputWorkspace">
        /// An ESRI ArcGIS Workspace Object that points to the Enterprise Geodatabase that is being used as the source for updating the Output File Geodatabase datasets.
        /// </param>
        /// <param name="InputWorkspaceDBSchemaOwnerName">
        /// The Name of the Schema Owner in the source Enterprise Geodatabase.
        /// </param>
        /// <returns>
        /// TRUE if all locators in which the udpated feature class participates have been rebuilt successfully.
        /// FALSE if the locators were not successfully rebuilt.
        /// </returns>
        public bool UpdateFileGeodatabaseLocators(string OutputFileGeodatabasePathName, string FeatureClassName, ESRI.ArcGIS.Geodatabase.IWorkspace InputWorkspace, string InputWorkspaceDBSchemaOwnerName)
        {
            ESRI.ArcGIS.Geodatabase.IWorkspace              geodatabaseWorkspace         = null;
              ESRI.ArcGIS.Location.ILocatorManager            locatorManager               = null;
              ESRI.ArcGIS.Geodatabase.ILocatorWorkspace2      locatorWorkspace             = null;
              ESRI.ArcGIS.Geodatabase.IEnumLocatorName        locatorNamesEnum             = null;
              System.Collections.Specialized.StringCollection copiedReferenceTables        = null;
              ESRI.ArcGIS.Geodatabase.ILocatorName            currentLocatorName           = null;
              ESRI.ArcGIS.Geodatabase.ILocator                currentLocator               = null;
              ESRI.ArcGIS.Location.IReferenceDataTables       locatorReferenceTables       = null;
              ESRI.ArcGIS.Location.IEnumReferenceDataTable    locatorReferenceTablesEnum   = null;
              ESRI.ArcGIS.Location.IReferenceDataTable2       currentLocatorReferenceTable = null;
              ESRI.ArcGIS.Geodatabase.IFeatureWorkspace       geodatabaseFeatureWorkspace  = null;
              ESRI.ArcGIS.Geodatabase.ITable                  deleteTable                  = null;
              ESRI.ArcGIS.Geodatabase.IDataset                deleteDataset                = null;
              ESRI.ArcGIS.Geodatabase.IFeatureWorkspace       inputFeatureWorkspace        = null;
              ESRI.ArcGIS.Geodatabase.ITable                  inputAlternateNameTable      = null;
              ESRI.ArcGIS.Geodatabase.IDataset                inputTableDataset            = null;
              ESRI.ArcGIS.Geodatabase.IWorkspaceFactory       inputWorkspaceFactory        = null;
              ESRI.ArcGIS.Geoprocessing.GeoProcessor          geoProcessorObject           = null;
              ESRI.ArcGIS.esriSystem.IVariantArray            tableToTableParams           = null;
              ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult   geoprocessorResult           = null;
              ESRI.ArcGIS.Geoprocessing.GeoProcessor          rebuildGeoprocessorObject    = null;
              ESRI.ArcGIS.esriSystem.IVariantArray            rebuildLocatorParams         = null;
              ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult   rebuildGeoprocessorResult    = null;

              try
              {
            //  Let the user know what is happening.
            if (ProcessMessage != null)
            {
              ProcessMessage("       - Initializing the process to rebuild any locators and determining if the specified Feature Class is a reference dataset for any locators in the File Geodatabase...");
            }

            //  Open the Locator Workspace.
            geodatabaseWorkspace = EstablishFileGeodatabaseConnection(OutputFileGeodatabasePathName);
            //  Make sure the Output File Geodatabase Workspace Connection was established successfully before moving on.
            if (geodatabaseWorkspace == null)
            {
              //  Let the user know that the connection could not be established.
              if (ErrorMessage != null)
              {
            ErrorMessage("Failed to open the Output File Geodatabase Workspace - " + OutputFileGeodatabasePathName + ".  Aborting the Locator Rebuild!");
              }
              //  Return FALSE to the calling method to indicate that this method failed.
              return false;
            }
            locatorManager = new ESRI.ArcGIS.Location.LocatorManagerClass();
            locatorWorkspace = (ESRI.ArcGIS.Geodatabase.ILocatorWorkspace2)locatorManager.GetLocatorWorkspace(geodatabaseWorkspace);

            //  Get the list of Address Locator Names from the File Geodatabase.
            locatorNamesEnum = locatorWorkspace.get_LocatorNames(ESRI.ArcGIS.Geodatabase.esriLocatorQuery.esriLocator, "Address");

            //  Create a List of Reference Tables that are copied by this process so that they will not be copied multiple times if it is used by multiple locators.
            copiedReferenceTables = new System.Collections.Specialized.StringCollection();

            //  Go through the list of associated locators and rebuild them.
            currentLocatorName = locatorNamesEnum.Next();
            while (currentLocatorName != null)
            {
              //  If there is a valid Locator Name, rebuild the locator.
              if (currentLocatorName.Name.Length > 1)
              {
            //  Let the User know that the locator is being rebuilt.
            if (ProcessMessage != null)
            {
              ProcessMessage("          + Determining if the " + FeatureClassName + " Feature Class participates in the " + currentLocatorName.Name.ToString() + " Locator...");
            }
            //  Open the Current Locator.
            currentLocator = locatorWorkspace.GetLocator(currentLocatorName.Name);

            //  If the Current Locator is a composite Locator, skip it.
            if (!(currentLocator is ESRI.ArcGIS.Location.ICompositeLocator))
            {
              //  Determine if the specified Feature Class is a reference Dataset for the locator.
              locatorReferenceTables = (ESRI.ArcGIS.Location.IReferenceDataTables)currentLocator;
              locatorReferenceTablesEnum = locatorReferenceTables.Tables;
              locatorReferenceTablesEnum.Reset();
              //  Retrieve the First Table from the Locator.
              currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
              //  Default the Found the Locator Indicator to FALSE.
              bool foundIt = false;
              //  If the Updated Feature Class is the Primary Table for this locator, the locator needs to be rebuilt so default the 'FoundIt' indicator to true.
              while (currentLocatorReferenceTable != null)
              {
                //  Determine if the current table is the specified Feature Class Business Table.
                if (currentLocatorReferenceTable.DisplayName.ToUpper() == "PRIMARY TABLE")
                {
                  ESRI.ArcGIS.Geodatabase.IDatasetName currentFeatureClassName = null;
                  currentFeatureClassName = (ESRI.ArcGIS.Geodatabase.IDatasetName)currentLocatorReferenceTable.Name;
                  if (currentFeatureClassName.Name.ToString().ToUpper() == FeatureClassName.ToUpper())
                  {
                    //  Set the found the locator indicator to TRUE.
                    foundIt = true;
                  }
                }
                //  Retrieve the Next Table from the Locator.
                currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
              }
              //  If the specified Feature Class does participate in the current Locator, rebuild the Locator.
              if (foundIt)
              {
                //  Let the User know that the locator is being rebuilt.
                if (ProcessMessage != null)
                {
                  ProcessMessage("          + Starting the rebuild of the " + currentLocatorName.Name.ToString() + " Locator...");
                }
                //  Reset the Locator Reference Tables enumerator.
                locatorReferenceTablesEnum.Reset();
                //  Retrieve the First Table from the Locator.
                currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
                //  Go through the Locator Reference Tables and rebuild any Alternate Name Tables that are associated with the locator.
                while (currentLocatorReferenceTable != null)
                {
                  if (currentLocatorReferenceTable.DisplayName.ToUpper() == "ALTERNATE NAME TABLE")
                  {
                    ESRI.ArcGIS.Geodatabase.IDatasetName currentTableName = null;
                    currentTableName = (ESRI.ArcGIS.Geodatabase.IDatasetName)currentLocatorReferenceTable.Name;
                    //  Alternate Name Tables have the string "_ALT" inserted in the name before the "_PDX" so, remove the "_PDX" from the Feature Class Name so that it can be
                    //  found in the Alternate Table Name.
                    string searchName = FeatureClassName;
                    if (searchName.Substring(searchName.Length - 3).ToUpper() == "PDX")
                    {
                      searchName = searchName.Substring(0, searchName.Length - 4);
                    }
                    //  If the current Alternate Name Table is associated with this locator, delete it and  copy the most current version from the source Geodatabase.
                    if (currentTableName.Name.ToString().ToUpper().IndexOf(searchName.ToUpper()) != -1)
                    {
                      //  If the Table Name includes some prefix information (Database Name and Table Owner Name), drop it for attempting to find the table in the search Geodatabase.
                      string tableSearchName = currentTableName.Name.ToString();
                      if (tableSearchName.ToUpper().IndexOf(searchName.ToUpper()) > 0)
                      {
                        //  Drop the prefix from the Table Name.
                        tableSearchName = tableSearchName.Substring(tableSearchName.IndexOf(searchName.ToUpper()));
                      }
                      //  If the Table has not already been updated by this process, update it.
                      if (!copiedReferenceTables.Contains(tableSearchName))
                      {
                        //  Let the user know which locator is being rebuilt.
                        if (ProcessMessage != null)
                        {
                          ProcessMessage("             < Deleting the - " + tableSearchName + " Alternate Name Table for the " + currentLocatorName.Name + " locator...");
                        }
                        geodatabaseFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)geodatabaseWorkspace;
                        deleteTable = geodatabaseFeatureWorkspace.OpenTable(currentTableName.Name.ToString());
                        deleteDataset = (ESRI.ArcGIS.Geodatabase.IDataset)deleteTable;
                        deleteDataset.Delete();
                        //  Release the Delete Objects to remove locks on the reference table.
                        if (deleteDataset != null)
                        {
                          System.Runtime.InteropServices.Marshal.ReleaseComObject(deleteDataset);
                        }
                        if (deleteTable != null)
                        {
                          System.Runtime.InteropServices.Marshal.ReleaseComObject(deleteTable);
                        }
                        //  Attempt to open the Source Table in the Input Geodatabase.
                        inputFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)InputWorkspace;

                        inputAlternateNameTable = (ESRI.ArcGIS.Geodatabase.ITable)inputFeatureWorkspace.OpenTable(InputWorkspaceDBSchemaOwnerName + "." + tableSearchName);
                        inputTableDataset = (ESRI.ArcGIS.Geodatabase.IDataset)inputAlternateNameTable;
                        //  If the Table was opened successfully, Attempt to Copy it to the File Geodatabase.
                        string temporaryDirectory = null;
                        if (inputAlternateNameTable != null)
                        {
                          //  Determine in which directory the Temporary SDE Connection File should
                          //  be created.
                          if (System.IO.Directory.Exists(@"D:\Temp"))
                          {
                            //  Set the Temporary Directory to 'D:\TEMP\'.
                            temporaryDirectory = @"D:\Temp\";
                          }
                          else
                          {
                            //  Check to see if there is a 'C:\TEMP' Directory.
                            if (System.IO.Directory.Exists(@"C:\Temp"))
                            {
                              //  Set the Temporary Directory to 'C:\Temp\'
                              temporaryDirectory = @"C:\Temp\";
                            }
                            else
                            {
                              //  Set the Temporary Directory to 'C:\'.
                              temporaryDirectory = @"C:\";
                            }
                          }
                          //  Create a Connection File for the Input Enterprise Geodatabase Connection.
                          inputWorkspaceFactory = InputWorkspace.WorkspaceFactory;
                          inputWorkspaceFactory.Create(temporaryDirectory, "inputConnection.sde", InputWorkspace.ConnectionProperties, 0);
                          string connectionFile = temporaryDirectory + "\\inputConnection.sde";
                          //  Let the user know which locator is being rebuilt.
                          if (ProcessMessage != null)
                          {
                            ProcessMessage("             < Copying the - " + tableSearchName + " Alternate Name Table for the " + currentLocatorName.Name + " locator from the Source Geodatabase...");
                          }
                          //  Establish a Table Copy Geoprocessing Object to Copy the Enterprise
                          //  Enterprise Geodatabase Alternate Name Table to the File Geodatabase.
                          geoProcessorObject = new ESRI.ArcGIS.Geoprocessing.GeoProcessor();
                          tableToTableParams = new ESRI.ArcGIS.esriSystem.VarArray();
                          tableToTableParams.Add(connectionFile + @"\" + inputTableDataset.Name);
                          tableToTableParams.Add(OutputFileGeodatabasePathName);
                          tableToTableParams.Add(tableSearchName);
                          //  Copy the Enterprise Geodatabase Alternate Name table to the File
                          //  Geodatabase.
                          geoprocessorResult = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)geoProcessorObject.Execute("TableToTable_conversion", tableToTableParams, null);
                          //  Delete the Connection File since it is no longer needed.
                          if (System.IO.File.Exists(temporaryDirectory + "\\inputConnection.sde"))
                          {
                            //  Delete the file.
                            System.IO.File.Delete(temporaryDirectory + "\\inputConnection.sde");
                          }
                          if (geoProcessorObject != null)
                          {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(geoProcessorObject);
                          }
                          if (tableToTableParams != null)
                          {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(tableToTableParams);
                          }
                          if (geoprocessorResult != null)
                          {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(geoprocessorResult);
                          }
                          //  Add the current table to the list of Tables that have been copied.
                          copiedReferenceTables.Add(tableSearchName);
                        }
                      }
                    }
                  }
                  //  Get the next Reference Table from the enumerator.
                  currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
                }
                //  Let the user know which locator is being rebuilt.
                if (ProcessMessage != null)
                {
                  ProcessMessage("             < Rebuilding the - " + currentLocatorName.Name + " locator...");
                }
                //  Build the Parameter Set necessary to Rebuild the Locator.
                rebuildLocatorParams = new ESRI.ArcGIS.esriSystem.VarArray();
                rebuildLocatorParams.Add(OutputFileGeodatabasePathName + "\\" + currentLocatorName.Name);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocatorName);
                if (currentLocatorReferenceTable != null)
                {
                  System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocatorReferenceTable);
                }
                if (currentLocator != null)
                {
                  System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocator);
                }
                //  Attempt to rebuild the Locator.
                rebuildGeoprocessorObject = new ESRI.ArcGIS.Geoprocessing.GeoProcessor();
                rebuildGeoprocessorResult = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)rebuildGeoprocessorObject.Execute("RebuildAddressLocator_geocoding", rebuildLocatorParams, null);
                //  Present the results of the process to the user.
                if (rebuildGeoprocessorResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
                {
                  //  Let the user know that the Locator was rebuilt successfully.
                  if (ProcessMessage != null)
                  {
                    ProcessMessage("               + Successfully rebuilt the - " + currentLocatorName.Name + " locator...");
                    if (rebuildGeoprocessorObject.MessageCount > 0)
                    {
                      ProcessMessage("               + The messages from the process were -");
                      for (int i = 0; i <= rebuildGeoprocessorObject.MessageCount - 1; i++)
                      {
                        ProcessMessage("                  - " + rebuildGeoprocessorObject.GetMessage(i));
                      }
                    }
                  }
                }
                else
                {
                  //  Let the user know that the Locator Failed to Rebuild.
                  if (ProcessMessage != null)
                  {
                    ProcessMessage("");
                    ProcessMessage("FAILED to rebuild the - " + currentLocatorName.Name + " locator...");
                    if (rebuildGeoprocessorObject.MessageCount > 0)
                    {
                      ProcessMessage("   + The messages from the process were -");
                      for (int i = 0; i <= rebuildGeoprocessorObject.MessageCount - 1; i++)
                      {
                        ProcessMessage("      - " + rebuildGeoprocessorObject.GetMessage(i));
                      }
                    }
                  }
                  //  Return FALSE to the calling method to indicate that this process failed.
                  return false;
                }
              }
            }
            else
            {
              //  Retrieve the list of locators that exist in the Composite Locator.
              ESRI.ArcGIS.Location.ICompositeLocator currentCompositeLocator = (ESRI.ArcGIS.Location.ICompositeLocator)currentLocator;
              string[] locatorNames = currentCompositeLocator.LocatorNames as string[];
              ESRI.ArcGIS.Geodatabase.ILocator[] locators = new ESRI.ArcGIS.Geodatabase.ILocator[locatorNames.Length];
              int i = 0;
              foreach (string currentSubLocatorName in locatorNames)
              {
                locators[i] = currentCompositeLocator.get_Locator(currentSubLocatorName);
                i++;
              }
              //  Determine if the Updated Feature Class participates in any of the locators in the Composite Locator.
              bool foundIt = false;
              foreach (ESRI.ArcGIS.Geodatabase.ILocator currentSubLocator in locators)
              {
                //  If the Current Locator is a Composite Locator, ignore it.
                if (!(currentSubLocator is ESRI.ArcGIS.Location.ICompositeLocator))
                {
                  //  Determine if the specified Feature Class is a reference Dataset for the locator.
                  locatorReferenceTables = (ESRI.ArcGIS.Location.IReferenceDataTables)currentSubLocator;
                  locatorReferenceTablesEnum = locatorReferenceTables.Tables;
                  locatorReferenceTablesEnum.Reset();
                  //  Retrieve the First Table from the Locator.
                  currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
                  //  Go through the Primary Tables participating in the Locator and determine if the Updated Feature Class Table is one of them.
                  while ((currentLocatorReferenceTable != null) && (!foundIt))
                  {
                    //  Determine if the current table is the specified Feature Class Business Table.
                    if (currentLocatorReferenceTable.DisplayName.ToUpper() == "PRIMARY TABLE")
                    {
                      ESRI.ArcGIS.Geodatabase.IDatasetName currentFeatureClassName = null;
                      currentFeatureClassName = (ESRI.ArcGIS.Geodatabase.IDatasetName)currentLocatorReferenceTable.Name;
                      if (currentFeatureClassName.Name.ToString().ToUpper() == FeatureClassName.ToUpper())
                      {
                        //  Set the found the locator indicator to TRUE.
                        foundIt = true;
                      }
                    }
                    //  Retrieve the Next Table from the Locator.
                    currentLocatorReferenceTable = (ESRI.ArcGIS.Location.IReferenceDataTable2)locatorReferenceTablesEnum.Next();
                  }
                }
              }
              //  If the Updated Feature Class is a member of the Composite Locator, rebuild it.
              if (foundIt)
              {
                //  Let the user know which locator is being rebuilt.
                if (ProcessMessage != null)
                {
                  ProcessMessage("             < Rebuilding the - " + currentLocatorName.Name + " locator...");
                }
                //  Build the Parameter Set necessary to Rebuild the Locator.
                rebuildLocatorParams = new ESRI.ArcGIS.esriSystem.VarArray();
                rebuildLocatorParams.Add(OutputFileGeodatabasePathName + "\\" + currentLocatorName.Name);
                //  Attempt to rebuild the Locator.
                rebuildGeoprocessorObject = new ESRI.ArcGIS.Geoprocessing.GeoProcessor();
                rebuildGeoprocessorResult = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)rebuildGeoprocessorObject.Execute("RebuildAddressLocator_geocoding", rebuildLocatorParams, null);
                //  Present the results of the process to the user.
                if (rebuildGeoprocessorResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
                {
                  //  Let the user know that the Locator was rebuilt successfully.
                  if (ProcessMessage != null)
                  {
                    ProcessMessage("               + Successfully rebuilt the - " + currentLocatorName.Name + " locator...");
                    if (rebuildGeoprocessorObject.MessageCount > 0)
                    {
                      ProcessMessage("               + The messages from the process were -");
                      for (int y = 0; y <= rebuildGeoprocessorObject.MessageCount - 1; y++)
                      {
                        ProcessMessage("                  - " + rebuildGeoprocessorObject.GetMessage(y));
                      }
                    }
                  }
                }
                else
                {
                  //  Let the user know that the Locator Failed to Rebuild.
                  if (ProcessMessage != null)
                  {
                    ProcessMessage("");
                    ProcessMessage("FAILED to rebuild the - " + currentLocatorName.Name + " locator...");
                    if (rebuildGeoprocessorObject.MessageCount > 0)
                    {
                      ProcessMessage("   + The messages from the process were -");
                      for (int y = 0; y <= rebuildGeoprocessorObject.MessageCount - 1; y++)
                      {
                        ProcessMessage("      - " + rebuildGeoprocessorObject.GetMessage(y));
                      }
                    }
                  }
                  //  Return FALSE to the calling method to indicate that this process failed.
                  return false;
                }
              }
            }

              }

              //  Retrieve the next Locator Name Object from the Locator Names Enumerator.
              currentLocatorName = locatorNamesEnum.Next();

            }

            //  If the process made it to here, it was successful so return TRUE to the calling routine.
            return true;

              }
              catch (System.Runtime.InteropServices.COMException comCaught)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(comCaught, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this process failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The FeatureClassUtilities.UpdateFileGeodatabaseLocators() Method failed with error message:  " + comCaught.Message + "(" + comCaught.ErrorCode + " Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return FALSE to the calling routine to indicate that this process failed.
            return false;

              }
              catch (System.Exception caught)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(caught, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this process failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The FeatureClassUtilities.UpdateFileGeodatabaseLocators() Method failed with error message:  " + caught.Message + " (Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return FALSE to the calling routine to indicate that this process failed.
            return false;

              }
              finally
              {
            //  If the Geoprocessor Result Object was instantiated, close it.
            if (geoprocessorResult != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(geoprocessorResult);
            }
            //  If the Table to Table Variant Array was instantiated, close it.
            if (tableToTableParams != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(tableToTableParams);
            }
            //  If the Geoprocessor Object was instantiated, close it.
            if (geoProcessorObject != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(geoProcessorObject);
            }
            //  If the InputWorkspace Factory Object was instantiated, close it.
            if (inputWorkspaceFactory != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(inputWorkspaceFactory);
            }
            //  If the Input Table Dataset Object was instantiated, close it.
            if (inputTableDataset != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(inputTableDataset);
            }
            //  If the Input Alternate Name Table Object was instantiated, close it.
            if (inputAlternateNameTable != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(inputAlternateNameTable);
            }
            //  If the Input Feature Workspace Object was instantiated, close it.
            if (inputFeatureWorkspace != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(inputFeatureWorkspace);
            }
            //  If the Delete Dataset Object was instantiated, close it.
            if (deleteDataset != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(deleteDataset);
            }
            //  If the Delete Table Object was instantiated, close it.
            if (deleteTable != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(deleteTable);
            }
            //  If the Geodatabase Feature Workspace Object was instantiated, close it.
            if (geodatabaseFeatureWorkspace != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(geodatabaseFeatureWorkspace);
            }
            //  If the Current Locator Reference Table Object was instantiated, close it.
            if (currentLocatorReferenceTable != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocatorReferenceTable);
            }
            //  If the Locator Reference Tables Enumerator was instantiated, close it.
            if (locatorReferenceTablesEnum != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorReferenceTablesEnum);
            }
            //  If the Locator Reference Tables Object was instantiated, close it.
            if (locatorReferenceTables != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorReferenceTables);
            }
            //  If the Current Locator Object was instantiated, close it.
            if (currentLocator != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocator);
            }
            //  If the Current Locator Name Object was instantiated, close it.
            if (currentLocatorName != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(currentLocatorName);
            }
            //  If the Locatore Names Enumerator Object was instantiated, close it.
            if (locatorNamesEnum != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorNamesEnum);
            }
            //  If the Locator Workspace Object was instantiated, close it.
            if (locatorWorkspace != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorWorkspace);
            }
            //  If the Locator Manager Object was instantiated, close it.
            if (locatorManager != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorManager);
            }
            //  If the Geodatabase Workspace Object was instantiated, close it.
            if (geodatabaseWorkspace != null)
            {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(geodatabaseWorkspace);
            }

              }
        }
示例#24
0
        /// <summary>
        /// Проверка на совместимость типов
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        static public TypesCompatibilities Check(Type from, Type to)
        {
            TypesCompatibilities retValue;
            long key = (((long)from.GetHashCode()) << 32) + to.GetHashCode();

            if (_cacheCheck.TryGetValue(key, out retValue))
            {
                return(retValue);
            }

            if (from == to)
            {
                retValue = TypesCompatibilities.Equal;
                lock (_cacheCheck)
                {
                    if (!_cacheCheck.ContainsKey(key))
                    {
                        _cacheCheck.Add(key, retValue);
                    }
                }

                return(retValue);
            }

            if (from.IsSubclassOf(to))
            {
                retValue = TypesCompatibilities.Convertable;
                lock (_cacheCheck)
                {
                    if (!_cacheCheck.ContainsKey(key))
                    {
                        _cacheCheck.Add(key, retValue);
                    }
                }

                return(retValue);
            }

            if (from == typeof(object) || to == typeof(object))
            {
                retValue = TypesCompatibilities.Convertable;
                lock (_cacheCheck)
                {
                    if (!_cacheCheck.ContainsKey(key))
                    {
                        _cacheCheck.Add(key, retValue);
                    }
                }

                return(retValue);
            }

            // стандартный Convert

            // System.Reflection.ConstructorInfo ci =from.GetConstructor(new System.Type[0]);
            //              try
            //              {
            //                  object obj = ci.Invoke(new object[0]);
            //                  if (obj!=null)
            //                  {
            //                      obj =  Convert.ChangeType(obj,to);
            //                      return TypesCompatibilities.Convertable;
            //                  }
            //                  else if (!to.IsValueType)
            //                      return TypesCompatibilities.Convertable;
            //              }
            //              catch
            //              {}
            // implicit преобразования
            if (_checkedTypes == null)
            {
                lock (_lockConst)
                {
                    if (_checkedTypes == null)
                    {
                        _checkedTypes = new System.Collections.Specialized.StringCollection();
                        _canConvertTo = new System.Collections.SortedList();
                        _knownTypes   = new System.Collections.Specialized.StringCollection();

                        // predefined implicit conversion
                        // bool
                        AddPredifinedConvertion(
                            typeof(bool),
                            new Type[] { },
                            new[] { typeof(int) });

                        // typeof(byte)
                        AddPredifinedConvertion(
                            typeof(byte),
                            new Type[] { },
                            new[]
                        {
                            typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long),
                            typeof(ulong),
                            typeof(float), typeof(double), typeof(decimal)
                        });

                        // typeof(sbyte)
                        AddPredifinedConvertion(
                            typeof(sbyte),
                            new Type[] { },
                            new[]
                        {
                            typeof(short), typeof(int), typeof(long), typeof(float), typeof(double),
                            typeof(decimal)
                        });

                        // typeof(char)
                        AddPredifinedConvertion(
                            typeof(char),
                            new Type[] { },
                            new[]
                        {
                            typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong),
                            typeof(float),
                            typeof(double), typeof(decimal)
                        });

                        // typeof(int)
                        AddPredifinedConvertion(
                            typeof(int),
                            new[] { typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(char) },
                            new[] { typeof(long), typeof(float), typeof(double), typeof(decimal) });

                        // typeof(uint)
                        AddPredifinedConvertion(
                            typeof(uint),
                            new[] { typeof(byte), typeof(ushort), typeof(char) },
                            new[] { typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) });

                        // typeof(long)
                        AddPredifinedConvertion(
                            typeof(long),
                            new[]
                        {
                            typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int),
                            typeof(uint),
                            typeof(char)
                        },
                            new[] { typeof(float), typeof(double), typeof(decimal) });

                        // typeof(ulong)
                        AddPredifinedConvertion(
                            typeof(ulong),
                            new[] { typeof(byte), typeof(ushort), typeof(uint), typeof(char) },
                            new[] { typeof(float), typeof(double), typeof(decimal) });

                        // typeof(short)
                        AddPredifinedConvertion(
                            typeof(short),
                            new Type[] { },
                            new[] { typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) });

                        // typeof(ushort)
                        AddPredifinedConvertion(
                            typeof(ushort),
                            new[] { typeof(byte), typeof(char) },
                            new[]
                        {
                            typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float),
                            typeof(double),
                            typeof(decimal)
                        });

                        // typeof(string)
                        AddPredifinedConvertion(
                            typeof(string),
                            new[]
                        {
                            typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float),
                            typeof(double), typeof(decimal)
                        },
                            new Type[] { });

                        // typeof(Guid)
                        AddPredifinedConvertion(
                            typeof(Guid),
                            new Type[] { },
                            new[] { typeof(string) });
                    }
                }
            }

            if (!_checkedTypes.Contains(from.FullName))
            {
                AddType(from);
            }

            if (!_checkedTypes.Contains(to.FullName))
            {
                AddType(to);
            }

            if (_canConvertTo.ContainsKey(from.FullName))
            {
                System.Collections.Specialized.StringCollection sl = (System.Collections.Specialized.StringCollection)_canConvertTo[from.FullName];
                if (sl.Contains(to.FullName))
                {
                    retValue = TypesCompatibilities.Convertable;
                    lock (_cacheCheck)
                    {
                        if (!_cacheCheck.ContainsKey(key))
                        {
                            _cacheCheck.Add(key, retValue);
                        }
                    }

                    return(retValue);
                }

                if (_knownTypes.Contains(from.FullName) && _knownTypes.Contains(to.FullName) &&
                    FoundTransform(from.FullName, to.FullName))
                {
                    retValue = TypesCompatibilities.Convertable;
                    lock (_cacheCheck)
                    {
                        if (!_cacheCheck.ContainsKey(key))
                        {
                            _cacheCheck.Add(key, retValue);
                        }
                    }

                    return(retValue);
                }

                retValue = TypesCompatibilities.No;
                lock (_cacheCheck)
                {
                    if (!_cacheCheck.ContainsKey(key))
                    {
                        _cacheCheck.Add(key, retValue);
                    }
                }

                return(retValue);
            }

            if (_knownTypes.Contains(from.FullName) && _knownTypes.Contains(to.FullName) &&
                FoundTransform(from.FullName, to.FullName))
            {
                retValue = TypesCompatibilities.Convertable;
                lock (_cacheCheck)
                {
                    if (!_cacheCheck.ContainsKey(key))
                    {
                        _cacheCheck.Add(key, retValue);
                    }
                }

                return(retValue);
            }

            retValue = TypesCompatibilities.No;
            lock (_cacheCheck)
            {
                if (!_cacheCheck.ContainsKey(key))
                {
                    _cacheCheck.Add(key, retValue);
                }
            }

            return(retValue);
        }