Ejemplo n.º 1
0
 internal AccessControlList(AccessControlListSettings sett)
 {
     foreach (AccessControlEntrySettings entry in sett.Entries)
     {
         entries.Add(entry.Username, new AccessControlEntry(entry));
     }
 }
Ejemplo n.º 2
0
        public void UpdateKey(TKey oldKey, TKey newKey)
        {
            var item = FSortedList[oldKey];

            FSortedList.Remove(oldKey);
            FSortedList.Add(newKey, item);

            OnOrderChanged();
        }
Ejemplo n.º 3
0
        public bool StartConnection()
        {
            _strCon = SetupConnection(m_strProvider, m_strServer, m_strDatabase,
                                      m_strUserName, m_strPassword, m_UseSSL);

            string DefDebug = "Provider=" + m_strProvider + ";Initial Catalog=REG_SIBS;" +
                              "User Id=" + m_strUserName + ";Password="******";Data Source = " + m_strServer;

            ConDebug.Add(_strGuid, DefDebug);

            return(TryLogin());
        }
Ejemplo n.º 4
0
 public async Task <System.Collections.Generic.SortedList <string, string> > GetHeaderAsync()
 {
     return(await Task.Run(() =>
     {
         var list = new System.Collections.Generic.SortedList <string, string>();
         list.Add("appkey", _AppKey);
         list.Add("apptoken", AppToken);
         list.Add("noncestr", Guid.NewGuid().ToString("N"));
         list.Add("usertoken", _UserToken);
         var sign = GetSign(list);
         list.Add("sign", sign);
         return list;
     }));
 }
Ejemplo n.º 5
0
 public void AddSchema(string tableName, Table schema)
 {
     if (!schemaCollection.ContainsKey(tableName))
     {
         schemaCollection.Add(tableName, schema);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// O(log(n))
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void Add(TKey key, TValue value)
        {
            KeyValuePair <TKey, TValue> kvp = new KeyValuePair <TKey, TValue>(key, value);
            LinkedListNode <KeyValuePair <TKey, TValue> > llNode = new LinkedListNode <KeyValuePair <TKey, TValue> >(kvp);

            if (sortedList.ContainsKey(key))
            {
                Remove(key);
            }
            linkedList.AddFirst(llNode); //O(1)
            sortedList.Add(key, llNode); //O(log(n))
            //see if there are too many values, if it is: remove one or several...
            while (sortedList.Count > this.currentPoolSize)
            {
                if (this.currentPoolSize < this.maxPoolSize && this.listCanExpandDelegate(this))
                {
                    //extend list size
                    this.currentPoolSize = Math.Min(sortedList.Count, this.maxPoolSize);
                }
                else
                {
                    LinkedListNode <KeyValuePair <TKey, TValue> > lastNode = linkedList.Last; //O(1)
                    sortedList.Remove(lastNode.Value.Key);                                    //O(log(n))
                    linkedList.Remove(lastNode);                                              //O(1)
                    //trigger an event to inform those who are interested that the node has become impopular
                    if (this.PopularityLost != null)
                    {
                        this.PopularityLost(lastNode.Value.Key, lastNode.Value.Value);
                    }
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds a communication  <see cref="ICommunicationLayerId"/> item to the list.
 /// </summary>
 /// <param name="value">The <see cref="ICommunicationLayerId"/> object to add to the list.</param>
 /// <returns>The position into which the new element was inserted.</returns>
 protected void Add(ICommunicationLayerId value)
 {
     m_CommunicationLayerIdColl.Add(value.Title, value);
     if (m_SelectedCommunicationLayerId == null)
     {
         m_SelectedCommunicationLayerId = value;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 加载已经配置的程式文件
 /// </summary>
 private void LoadLocalRoutines()
 {
     if (System.IO.Directory.Exists(_routineBaseDirectory))
     {
         string[] directories = System.IO.Directory.GetDirectories(_routineBaseDirectory);
         if (directories != null &&
             directories.Length > 0)
         {
             int    count = directories.Length;
             string routineName;
             for (int i = 0; i < count; i++)
             {
                 routineName = System.IO.Path.GetFileNameWithoutExtension(directories[i]);
                 _routineNamesAndDirectories.Add(routineName, directories[i]);
             }
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 方法:初始化(覆写实现)
        /// </summary>
        public override void DoIni()
        {
            try
            {
                if (_cameraList != null &&
                    _cameraList.Count > 0)
                {
                    for (int i = 0; i < _cameraList.Count; i++)
                    {
                        ProDriver.APIHandle.CameraAPIHandle camAPI = new ProDriver.APIHandle.CameraAPIHandle(_cameraList[i]);
                        camAPI.ImageGrabbedEvt += Device_Camera_ImageGrabbedEvt;
                        CamHandleList.Add(_cameraList[i].ID, camAPI);
                        _camGrabbedList.Add(_cameraList[i].ID, false);

                        if (!_cameraList[i].IsConnected)
                        {
                            CamHandleList[_cameraList[i].ID].EnumerateCameraList(); //枚举相机列表
                            if (CamHandleList[_cameraList[i].ID].GetCameraBySN(_cameraList[i].SerialNo))
                            {
                                if (!CamHandleList[_cameraList[i].ID].Open())
                                {
                                    if (!_timer.Enabled)
                                    {
                                        StartTimer();  //第一连接失败,需要启动定时器,因为相机连接状态更新的值与原来的值一样,不会触发属性值改变事件
                                    }
                                    return;
                                }
                                else
                                {
                                    _cameraList[i].IsActive    = true;
                                    _cameraList[i].IsConnected = true;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    if (!_isCameraInitialized)
                    {
                        InitCamera();
                        _isCameraInitialized = true;
                        InitVisionLogic();
                    }
                }
            }
            catch (Exception ex)
            {
                //ProCommon.Communal.LogWriter.WriteException(_exLogFilePath, ex);
                //ProCommon.Communal.LogWriter.WriteLog(_sysLogFilePath, string.Format("错误:初始化相机设备失败!\n异常描述:{0}", ex.Message));
                //throw new ProCommon.Communal.InitException(ToString(), "初始化异常\n" + ex.Message);
            }
        }
Ejemplo n.º 10
0
        public static void DumpOpcodes()
        {
            var files = System.IO.Directory.GetFiles(@"E:\HFS\WOWDEV\SNIFFS_CLEAN\", "*.sqlite", System.IO.SearchOption.AllDirectories).OrderBy(t => t);

            var versionOpcodeList = new System.Collections.Generic.SortedList<uint, ClientBuildCache>();

            foreach (var file in files)
            {
                uint clientBuild = 0;

                using (var con = new System.Data.SQLite.SQLiteConnection("Data Source=" + file))
                {
                    con.Open();
                    using (var sqlcommand = con.CreateCommand())
                    {
                        sqlcommand.CommandText = "select key, value from header where key = 'clientBuild'";
                        var reader = sqlcommand.ExecuteReader();

                        while (reader.Read())
                        {
                            clientBuild = (uint)reader.GetInt32(1);
                            break;
                        }
                    }

                    if (!versionOpcodeList.ContainsKey(clientBuild))
                    {
                        versionOpcodeList.Add(clientBuild, new ClientBuildCache() { ClientBuild = clientBuild, OpcodeList = new List<OpcodeCache>() });
                    }

                    var clientBuildOpcodes = versionOpcodeList[clientBuild];

                    using (var sqlcommand = con.CreateCommand())
                    {
                        sqlcommand.CommandText = "select distinct opcode, direction from packets order by opcode , direction";
                        var reader = sqlcommand.ExecuteReader();

                        while (reader.Read())
                        {
                            var opcode = (uint)reader.GetInt32(0);
                            var direction = (byte)reader.GetInt32(1);

                            if (!clientBuildOpcodes.OpcodeList.Exists(t => t.Opcode == opcode && t.Direction == direction))
                                clientBuildOpcodes.OpcodeList.Add(new OpcodeCache() { Direction = direction, Opcode = opcode });
                        }
                    }

                    con.Close();
                }
            }

            var clientBuildOpcodeList = versionOpcodeList.Select(t => t.Value).ToList();

            clientBuildOpcodeList.SaveObject("clientBuildOpcodeList.xml");
        }
Ejemplo n.º 11
0
        public static string LargestNumberFromArray(int[] vs)
        {
            var sl = new System.Collections.Generic.SortedList <string, int>(new LargestComparer());

            foreach (var v in vs)
            {
                sl.Add(v.ToString(), v);
            }

            return(String.Join("", sl.Values.Select(v => v.ToString())));
        }
Ejemplo n.º 12
0
        public SortedViewableList(IEditableList <T> list, Func <T, TKey> keySelector)
            : base(list)
        {
            FSortedList  = new System.Collections.Generic.SortedList <TKey, T>();
            FKeySelector = keySelector;

            foreach (var item in list)
            {
                FSortedList.Add(FKeySelector(item), item);
            }
        }
Ejemplo n.º 13
0
        static void Sort(string inputdir = "", string outputdir = ".\\output")
        {
            Console.WriteLine("Hashing " + inputdir);
            System.Timers.Timer t = new System.Timers.Timer(5000);
            t.Elapsed += T_Elapsed;
            DateTime start = DateTime.Now;

            t.Start();

            (ConcurrentDictionary <string, Digest> gilePathsToHashes, ConcurrentDictionary <Digest, HashSet <string> > hashesToFiles) =
                GetHashes(
                    dirPath: inputdir,
                    searchPattern: "*.png");

            t.Stop();
            DateTime stop = DateTime.Now;

            Console.WriteLine("Hashed " + hashesToFiles.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s.");

            Console.WriteLine("Sorting " + inputdir);
            t.Elapsed -= T_Elapsed;
            t.Elapsed += T_Elapsed1;
            t.Start();
            start = DateTime.Now;
            SortedList <string, Digest> sortedPaths = new System.Collections.Generic.SortedList <string, Digest>(gilePathsToHashes.Count);

            foreach (var item in gilePathsToHashes)
            {
                sortedPaths.Add(item.Key.ToString(), item.Value);
            }
            stop = DateTime.Now;
            t.Stop();
            Console.WriteLine("Sorted " + sortedPaths.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s.");

            Console.WriteLine("Writing output files " + inputdir);
            t.Elapsed -= T_Elapsed1;
            t.Elapsed += T_Elapsed2;
            t.Start();
            start = DateTime.Now;
            int i = 1;

            foreach (var item in sortedPaths)
            {
                if (File.Exists(outputdir + "\\" + i + ".png"))
                {
                    File.Delete(outputdir + "\\" + i + ".png");
                }
                File.Copy(item.Key, outputdir + "\\" + i++ + ".png");
            }
            stop = DateTime.Now;
            t.Stop();
            Console.WriteLine("Copied " + sortedPaths.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s.");
        }
Ejemplo n.º 14
0
        private SortedList <string, Rfc822Message> getOutlookMessages()
        {
            System.Collections.Generic.SortedList <string, Rfc822Message> messages = new System.Collections.Generic.SortedList <string, Rfc822Message>();

            //Dim tempApp As Outlook.Application
            //Dim tempInbox As Outlook.MAPIFolder
            //Dim InboxItems As Outlook.Items
            //Dim tempMail As Object = Nothing
            //Dim objattachments, objAttach

            RDOSession session = null;

            //object inbox = null;
            try {
                //tempApp = New Outlook.Application

                session = (RDOSession)Interaction.CreateObject("Redemption.RDOSession");
                session.Logon();
            } catch (System.Exception ex) {
                GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, "Unable to create Outlook object: " + ex.Message, false);
                return(null);
            }
            //tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

            RDOFolder inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);

            //InboxItems = tempInbox.Items
            //Dim msg As Outlook.MailItem
            foreach (MailItem msg in inbox.Items)
            {
                //For Each msg In InboxItems
                if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag((Rfc822Message)msg).Trim()))
                {
                    if (!UtilFunctions.searchUID(msg.EntryID))
                    {
                        // No.  Add to list
                        messages.Add(msg.EntryID, (Rfc822Message)msg);
                    }
                }
                if (!runFlag | !isEnabled)
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
            }
            session.Logoff();
            string cnt = messages.Count.ToString();

            cnt += " Outlook messages were found";
            GlobalShared.Log.Log((int)LogClass.logType.Info, cnt, false);

            return(messages);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Temp: turn context1:value1,context2:value2,... into a dict
 /// </summary>
 static void AddColumnColonToDictionary(System.Collections.Generic.SortedList <string, string> facts,
                                        string input)
 {
     string[] pairs = input.Split(',');
     foreach (string p in pairs)
     {
         string[] kv = p.Split(':');
         if (kv.Length >= 2)
         {
             facts.Add(kv[0], kv[1]);
         }
     }
 }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            List <string> listTest = new List <string>();

            for (int i = 1; i <= 500000; i++)//50_0000
            {
                listTest.Add(i.ToString().PadLeft(10, '0'));
            }

            Stopwatch stopMatch = new Stopwatch();

            stopMatch.Start();
            List <string> listOrder = listTest.OrderByDescending(c => c).ToList <string>();

            stopMatch.Stop();

            Console.WriteLine("Linq排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString());

            stopMatch.Reset();

            stopMatch.Start();

            var sortedList = new System.Collections.Generic.SortedList <string, string>();

            foreach (var item in listTest)
            {
                sortedList.Add(item, item);
            }
            Console.WriteLine("SortedList排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString());
            stopMatch.Stop();

            string[] arrTest = listOrder.ToArray();

            stopMatch.Reset();
            stopMatch.Start();
            QuickSort(arrTest, 0, arrTest.Length - 1);

            stopMatch.Stop();

            Console.WriteLine("二分法排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString());


            Console.Read();
        }
Ejemplo n.º 17
0
        private void AddLocations(ISourceNode node, ref IPositionInfo lastNode, ref int lastCharPos, char[] chars)
        {
            int           location = 0;
            IPositionInfo posInfo  = (node as IAnnotated)?.Annotation <Hl7.Fhir.Serialization.XmlSerializationDetails>();

            if (posInfo == null)
            {
                posInfo = (node as IAnnotated)?.Annotation <Hl7.Fhir.Serialization.JsonSerializationDetails>();
            }
            if (posInfo != null)
            {
                if (lastNode == null)
                {
                    location = 0;
                }
                else
                {
                    var linesToSkip = posInfo.LineNumber - lastNode.LineNumber;
                    var colsToSkip  = posInfo.LinePosition;
                    if (linesToSkip == 0)
                    {
                        colsToSkip -= lastNode.LinePosition;
                    }
                    while (linesToSkip > 0 && lastCharPos < chars.Length)
                    {
                        lastCharPos++;
                        if (chars[lastCharPos] == '\r')
                        {
                            linesToSkip--;
                        }
                    }
                    lastCharPos += colsToSkip;
                    location     = lastCharPos; // need to patch this
                }
                lastNode = posInfo;
                _locations.Add(location, node.Location);
                // System.Diagnostics.Trace.WriteLine($"{location}: {node.Location}");
            }
            lastCharPos = location;
            foreach (var child in node.Children())
            {
                AddLocations(child, ref lastNode, ref lastCharPos, chars);
            }
        }
Ejemplo n.º 18
0
        public Variable Add(string Name)
        {
            // clean the name for the key
            Name = Name.Trim();
            string key = Name.ToLower();

            // check if the variable exists first
            if (VariableExists(key) == true)
            {
                return(this[key]);
            }
            else
            {
                // create the variable
                Variable var = new Variable(Name);
                items.Add(key, var);
                return(var);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by QName.
        /// Fill the index (sorted by QName) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private IList <string> SortByReadNames()
        {
            IList <string> files = new List <string>();

            var sortedList = new System.Collections.Generic.SortedList <object, string>();

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                string             indices    = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.QName, out indices))
                {
                    sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.QName] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (files == null)
                    {
                        files = new List <string>();
                    }

                    files.Add(WriteToFile(sortedList));
                    sortedList.Clear();
                }
            }

            if (sortedList.Count > 0)
            {
                files.Add(WriteToFile(sortedList));
                sortedList.Clear();
            }

            return(files);
        }
Ejemplo n.º 20
0
        void DisplayBestRuleForConcept(string concept, string factstring)
        {
            ObservableCollectionOfRules collection = (ObservableCollectionOfRules)this.FindResource("RulesMatchingDebuggerCriterion");

            collection.Clear();
            System.Collections.Generic.SortedList <string, string> facts = new System.Collections.Generic.SortedList <string, string>();
            facts.Add("concept", concept);
            AddColumnColonToDictionary(facts, factstring);

            foreach (KeyValuePair <Rule, float> pair in RRSys.FindAllRulesMatchingCriteria(facts))
            {
                collection.Add(pair);
            }

            /*
             * Rule bestMatchingRule = RRSys.FindBestMatchingRule( facts );
             * if ( bestMatchingRule != null )
             * {
             *  collection.Add(bestMatchingRule);
             * }
             */
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Adds an integer value to the collection.
 /// </summary>
 /// <param name="nValue">The integer value to add.</param>
 public void Add(int nValue)
 {
     _list.Add(nValue, null);
 }
Ejemplo n.º 22
0
 private static void Add(ICommunicationLayerId value)
 {
     m_CommunicationLayerIdColl.Add(value.Title, value);
 }
Ejemplo n.º 23
0
    void OnGUI()
    {
        if (Input.GetKey(KeyCode.Tab))
        {
            // Get dimensions for the scoreboard.
            float fScoreboardWidth  = Screen.width * mfScoreboardWidthScalar;
            float fScoreboardHeight = Screen.height * mfScoreboardHeightScalar;
            float fScoreboardLeft   = (Screen.width - fScoreboardWidth) / 2;
            float fScoreboardTop    = (Screen.height - fScoreboardHeight) / 2;
            float fTextLeft         = fScoreboardLeft + fScoreboardWidth * (1.0f - mfTextWidthScalar);
            float fRowHeight        = fScoreboardHeight / muiNumRows;
            float fTextTop          = fScoreboardTop + fRowHeight * (1.0f - mfTextHeightScalar);
            float fTextWidth        = fScoreboardWidth * mfTextWidthScalar;
            float fColumnWidth      = fTextWidth / (int)EColumn.MAX;
            float fTextHeight       = fScoreboardHeight * mfTextHeightScalar;

            // Sort the scores
            System.Collections.Generic.SortedList <int, ScoreboardVarStruct> scoreboard = new System.Collections.Generic.SortedList <int, ScoreboardVarStruct>(mPlayers.Count);
            foreach (System.Collections.Generic.KeyValuePair <int, ScoreboardVarStruct> pair in mPlayers)
            {
                scoreboard.Add(pair.Value.iScore, pair.Value);
            }

            // Scoreboard.
            GUI.Box(new Rect(fScoreboardLeft,
                             fScoreboardTop,
                             fScoreboardWidth,
                             fScoreboardHeight),
                    "");

            // Print each of the column headers.
            for (int i = 0; i < (int)EColumn.MAX; ++i)
            {
                GUI.Label(new Rect(fTextLeft + fColumnWidth * i,
                                   fTextTop,
                                   fColumnWidth,
                                   fTextHeight),
                          maColumnName[i]);
            }

            UnityEngine.Color oldGuiColour = GUI.color;                 // Remember old GUI colour to restore it after drawing everything.

            // For each client
            uint uiPlayer = 0;
            foreach (System.Collections.Generic.KeyValuePair <int, ScoreboardVarStruct> pair in scoreboard)
            {
                ++uiPlayer;                     // +1 beforehand to skip row used by headers.

                string[] aPlayerStats = new string[(int)EColumn.MAX];
                aPlayerStats[(int)EColumn.Name]   = pair.Value.strName;
                aPlayerStats[(int)EColumn.Kills]  = pair.Value.iKills.ToString();
                aPlayerStats[(int)EColumn.Deaths] = pair.Value.iDeaths.ToString();
                aPlayerStats[(int)EColumn.Score]  = pair.Value.iScore.ToString();

                // Gray out 'dead' players
                GUI.color = pair.Value.bAlive ? Color.white : Color.gray;

                // Print out stats for each column.
                for (uint uiStat = 0; uiStat < (uint)EColumn.MAX; ++uiStat)
                {
                    GUI.Label(new Rect(fTextLeft + fColumnWidth * uiStat,
                                       fTextTop + fRowHeight * uiPlayer,
                                       fColumnWidth,
                                       fTextHeight),
                              pair.Value.strName);
                }
            }

            // Reset GUI colour.
            GUI.color = oldGuiColour;
        }
    }
Ejemplo n.º 24
0
        void _AsynQueryRule_GetBufferByIndexCompleted(object sender, MB.WinBase.Common.GetBufferByIndexCompletedEventArgs e)
        {
            int index = (int)e.UserState;

            _DataList.Add(index, e.Result);
        }
Ejemplo n.º 25
0
        private SortedList <string, Rfc822Message> getSmtpMessages()
        {
            Pop3Client target = new Pop3Client();

            target.Host = Host;
            //TCP port for connection
            target.Port = Convert.ToUInt16(Port);
            //Username to login to the POP3 server
            target.Username = Username;
            //Password to login to the POP3 server
            target.Password = Password;
            // SSL Interaction type
            Email.Net.Common.Configurations.EInteractionType interaction = default(Email.Net.Common.Configurations.EInteractionType);
            if (TSL)
            {
                interaction = EInteractionType.StartTLS;
            }
            else if (SSL)
            {
                interaction = EInteractionType.SSLPort;
            }
            else
            {
                interaction = EInteractionType.Plain;
            }
            target.SSLInteractionType = EInteractionType.SSLPort;
            target.AuthenticationType = EAuthenticationType.Login;
            if (authenticationType == (int)EAuthenticationType.None)
            {
                Password = "";
                Username = "";
            }

            System.Collections.Generic.SortedList <string, Rfc822Message> messages = new System.Collections.Generic.SortedList <string, Rfc822Message>();
            Rfc822Message msg = null;

            // Login to POP server
            try {
                Pop3Response response = target.Login();
                if (response.Type == EPop3ResponseType.OK)
                {
                    // Retrieve Unique IDs for all messages
                    Pop3MessageUIDInfoCollection messageUIDs = target.GetAllUIDMessages();
                    //Check if messages already received
                    foreach (Pop3MessageUIDInfo uidInfo in messageUIDs)
                    {
                        try {
                            msg = target.GetMessage(uidInfo.SerialNumber);
                        } catch (Email.Net.Common.Exceptions.ConnectionException ex) {
                        } catch (Email.Net.Common.Exceptions.AuthenticationMethodNotSupportedException ex) {
                        } catch (System.Exception ex) {
                        }
                        if ((msg != null))
                        {
                            if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag(msg).Trim()))
                            {
                                if (!UtilFunctions.searchUID(uidInfo.UniqueNumber))
                                {
                                    // No.  Add to list
                                    messages.Add(uidInfo.UniqueNumber, target.GetMessage(uidInfo.SerialNumber));
                                }
                            }
                        }
                        if (!runFlag | !isEnabled)
                        {
                            break;                             // TODO: might not be correct. Was : Exit For
                        }
                    }
                    string cnt = (messages.Count.ToString());
                    cnt += " SMTP messages were found";
                    GlobalShared.Log.Log((int)LogClass.logType.Info, cnt, false);
                }
                //Logout from the server
                target.Logout();
            } catch (IOException ex) {
                GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false);
            } catch (Email.Net.Common.Exceptions.ConnectionException ex) {
                GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false);
            } catch (System.Exception ex) {
                GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false);
            }
            return(messages);
        }
Ejemplo n.º 26
0
        public static System.Collections.Generic.SortedList<int, eJobStatus> GetStatusesOfJobs(int[] jobIDs)
        {
            System.Collections.Generic.SortedList<int, eJobStatus> jobStatusesList = new System.Collections.Generic.SortedList<int, eJobStatus>();
            DataTable dtResults = null;
            DataAccess objADO = new DataAccess();
            ArrayList colParameters = new ArrayList();
            System.Data.SqlClient.SqlParameter[] arrParameters = null;
            DataAccess.ArrayListParameter objParameter = null;
            string strStoredProcedure = "selStatusesForWMSourceIDs";

            objADO = Domain.GetADOInstance();

            objParameter = new DataAccess.ArrayListParameter("WMSourceIDs", jobIDs);
            dtResults = objADO.GetDataSet(strStoredProcedure, objParameter, arrParameters).Tables[0];
            objADO = null;

            if (dtResults.Rows.Count > 0)
            {
                foreach (DataRow drJobStatusInfo in dtResults.Rows)
                {
                    jobStatusesList.Add(int.Parse(drJobStatusInfo["WMSourceID"].ToString()), (eJobStatus)Enum.Parse(typeof(eJobStatus),drJobStatusInfo["JobStatus"].ToString()));
                }
            }

            return jobStatusesList;
        }
Ejemplo n.º 27
0
        public bool Open(string filename)
        {
            System.IO.FileStream   stream = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            System.IO.BinaryReader reader = new System.IO.BinaryReader(stream);
            bool re = true;

            try
            {
                byte[] magicbyte = reader.ReadBytes(52);

                string magicstring = System.Text.ASCIIEncoding.ASCII.GetString(magicbyte).Trim('\0');

                uint size       = reader.ReadUInt32();
                bool compressed = true;
                if (reader.ReadUInt32() == 0)
                {
                    compressed = false;
                }

                switch (magicstring)
                {
                case "KOG GC TEAM MASSFILE V.0.3.":

                    komtype = EKomType.newkom;

                    filetime    = reader.ReadUInt32();
                    adler32     = reader.ReadUInt32();
                    header_size = reader.ReadUInt32();

                    System.Xml.XmlDocument headerxml = new System.Xml.XmlDocument();

                    byte[] header_raw = reader.ReadBytes((int)header_size);

                    if (header_raw[0] != '<' ||
                        header_raw[1] != '?' ||
                        header_raw[2] != 'x' ||
                        header_raw[3] != 'm' ||
                        header_raw[4] != 'l')
                    {
                        if (ecb == null)
                        {
                            throw new EncryptedKomException();
                        }

                        byte[] data = (byte[])header_raw.Clone();
                        ecb.Decrypt(data, 0, header_raw, 0, (int)header_size);
                        komtype = EKomType.encrypt;
                    }
                    string xmlstring = System.Text.ASCIIEncoding.ASCII.GetString(header_raw);
                    headerxml.LoadXml(xmlstring);
                    System.Xml.XmlNodeList files = headerxml.SelectNodes("Files/File");

                    UInt32 offset = OffsetStart + header_size;

                    foreach (System.Xml.XmlElement file in files)
                    {
                        string      key     = file.GetAttribute("Name");
                        Kom2SubFile subfile = Kom2SubFile.ReadSubFileFromKom(ecb, filename, file, offset);
                        offset += subfile.CompressedSize;
                        subfiles.Add(key, subfile);
                    }
                    break;

                case "KOG GC TEAM MASSFILE V.0.1.":
                case "KOG GC TEAM MASSFILE V.0.2.":

                    komtype = EKomType.oldkom;
                    for (int i = 0; i < size; i++)
                    {
                        string      key     = System.Text.ASCIIEncoding.ASCII.GetString(reader.ReadBytes(60)).Trim('\0');
                        Kom2SubFile subfile = Kom2SubFile.ReadSubFileFromOldKom(filename, reader, 60 + size * 72);
                        if (key != "crc.xml")
                        {
                            subfiles.Add(key, subfile);
                        }
                    }
                    break;

                default:
                    re = false;
                    break;
                }
            }
            catch (System.Exception ex)
            {
                komtype = EKomType.notkom;
                re      = false;
            }

            stream.Close();
            return(re);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by QName.
        /// Fill the index (sorted by QName) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private IList<string> SortByReadNames()
        {
            IList<string> files = new List<string>();

            var sortedList = new System.Collections.Generic.SortedList<object,string>();

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                string indices = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.QName, out indices))
                {
                    sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.QName] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (files == null)
                    {
                        files = new List<string>();
                    }

                    files.Add(WriteToFile(sortedList));
                    sortedList.Clear();
                }
            }

            if (sortedList.Count > 0)
            {
                files.Add(WriteToFile(sortedList));
                sortedList.Clear();
            }
            
            return files;
        }
Ejemplo n.º 29
0
 public void AddKeyframe(int frame, TrackingInfo info)
 {
     keyframes.Remove(frame);
     keyframes.Add(frame, info);
 }
 private void FindUrls()
 {
     try
     {
         var typers = new Collection<Type>();
         var isrc = new System.Collections.Generic.SortedList<TypedDataSourceAttributeComparer, DataSourceAttribute>();
         KnownTypes.ItemsSource = isrc;
         foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
         {
             foreach (var itype in item.GetTypes())
             {
                 foreach (var cat in itype.GetCustomAttributes(typeof(DataSourceAttribute), false))
                 {
                     var xcat = (cat as DataSourceAttribute);
                     if (xcat.IgnoreClones)
                     {
                         foreach (var cloneposs in typers)
                         {
                             if (cloneposs == itype)
                             {
                                 goto noadd;
                             }
                         }
                     }
                     isrc.Add(new TypedDataSourceAttributeComparer { DataSourceAttribute = xcat, Type = itype }, xcat);
                     typers.Add(itype);
                 noadd:
                     continue;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorDialog.PrcException(new Exception("Error searching for Sources. This is most likely caused by a missing dependency. Is SlimDX installed?", ex));
     }
 }