public override void OnBackstabClientConnected(ConnectionData data)
 {
     boxMessage = "Client has connected.";
     Rpc("GetServerOk");
     Rpc("FlipMessageA");
     Rpc("FlipMessageB");
 }
示例#2
0
        private void parseBuffer(ConnectionData connectionData)
        {
            if (connectionData.Buffer.Length > 3)
            {
                int length = connectionData.Buffer.PeekInt();
                Logger.WriteConsole("Length is: " + length);

                if (length > 200)
                {
                    throw new Exception("BLAHHHHHH");
                }

                if (connectionData.Buffer.Length >= length + 4)
                {
                    byte[] lengthBytes = new byte[4];
                    connectionData.Buffer.Read(lengthBytes, 0, lengthBytes.Length);

                    byte[] data = new byte[length];
                    connectionData.Buffer.Read(data, 0, data.Length);
                    //_parser.ParseByMarshal(data);
                    _parser.ParseByRead(data);
                    parseBuffer(connectionData);
                }
            }
        }
示例#3
0
 private void SelectDatabaseForm_Load(object sender, EventArgs e)
 {
     if(!string.IsNullOrEmpty(ConnectionString))
     {
         var connData = new ConnectionData(ConnectionString);
         DatabaseName = connData.DatabaseName;
         Server = connData.Server;
     }
 }
 //webplayer
 public void connect()
 {
     if(Application.isWebPlayer) {
         ConnectionData data = new ConnectionData(gameVersion);
         string json = getJsonString(data);
         //logMessage("RedMetricsManager::connect will rmConnect json="+json);
         Application.ExternalCall("rmConnect", json);
     }
 }
 public void ReleaseConnection(ConnectionData c)
 {
     c.inUse = false;
     c.lastUse = DateTime.Now;
     lock (_mutex)
     {
         _connList[c.id] = c;
     }
     System.Diagnostics.Debug.WriteLine("Released (" + c.id + ") at: " + DateTime.Now.ToString("HH:mm:ss.ffff"));
     System.Diagnostics.Debug.WriteLine("Total of: " + _connList.Count());
 }
        private static void CheckMissingReceiveCallback(ConnectionData connectionData, IMonitoredTcpConnection connection)
        {
            bool inReceive = connection.InReceive;
            bool isReadyForReceive = connection.IsReadyForReceive;
            DateTime? lastReceiveStarted = connection.LastReceiveStarted;

            int sinceLastReceive = (int)(DateTime.UtcNow - lastReceiveStarted.GetValueOrDefault()).TotalMilliseconds;
            bool missingReceiveCallback = inReceive && isReadyForReceive && sinceLastReceive > 500;

            if (missingReceiveCallback && connectionData.LastMissingReceiveCallBack)
            {
                Log.Error("# {0} {1}ms since last Receive started. No completion callback received, but socket status is READY_FOR_RECEIVE",
                          connection, sinceLastReceive);
            }
            connectionData.LastMissingReceiveCallBack = missingReceiveCallback;
        }
        private TcpStats AnalyzeConnections(ConnectionData[] connections, TimeSpan measurePeriod)
        {
            _receivedSinceLastRun = 0;
            _sentSinceLastRun = 0;
            _pendingSendOnLastRun = 0;
            _inSendOnLastRun = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            var stats = new TcpStats(connections.Length,
                                     _sentTotal,
                                     _receivedTotal,
                                     _sentSinceLastRun,
                                     _receivedSinceLastRun,
                                     _pendingSendOnLastRun,
                                     _inSendOnLastRun,
                                     _pendingReceivedOnLastRun,
                                     measurePeriod);


            if (Application.IsDefined(Application.DumpStatistics))
            {
                Log.Trace("\n# Total connections: {0,3}. Out: {1:0.00}b/s  In: {2:0.00}b/s  Pending Send: {3}  " +
                          "In Send: {4}  Pending Received: {5} Measure Time: {6}",
                          stats.Connections,
                          stats.SendingSpeed,
                          stats.ReceivingSpeed,
                          stats.PendingSend,
                          stats.InSend,
                          stats.PendingSend,
                          stats.MeasureTime);
            }
            return stats;
        }
        private TcpStats AnalyzeConnections(ConnectionData[] connections, TimeSpan measurePeriod)
        {
            _receivedSinceLastRun = 0;
            _sentSinceLastRun = 0;
            _pendingSendOnLastRun = 0;
            _inSendOnLastRun = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            var stats = new TcpStats(connections.Length,
                                     _sentTotal,
                                     _receivedTotal,
                                     _sentSinceLastRun,
                                     _receivedSinceLastRun,
                                     _pendingSendOnLastRun,
                                     _inSendOnLastRun,
                                     _pendingReceivedOnLastRun,
                                     measurePeriod);

#if DUMP_STATISTICS
            _log.Debug("\n# Total connections: {0,3}. Out: {1:0.00}b/s  In: {2:0.00}b/s  Pending Send: {3}  " +
                       "In Send: {4}  Pending Received: {5} Measure Time: {6}",
                       stats.Connections,
                       stats.SendingSpeed,
                       stats.ReceivingSpeed,
                       stats.PendingSend,
                       stats.InSend,
                       stats.PendingSend,
                       stats.MeasureTime);
#endif
            return stats;
        }
示例#9
0
文件: LdapServer.cs 项目: MrJoe/lat
        public LdapServer(ConnectionData connectionData)
        {
            conn = new LdapConnection ();

            host = connectionData.Host;
            port = connectionData.Port;
            sType = Util.GetServerType (connectionData.ServerType);
            encryption = connectionData.Encryption;

            if (connectionData.DirectoryRoot != "")
                rootDN = connectionData.DirectoryRoot;

            profileName = connectionData.Name;

            adInfo = new ActiveDirectoryInfo ();
            SetServerType ();
        }
示例#10
0
        protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
        {
            CommonHandlers.ActionBeforeQueryStatusSolutionExplorerCSharpSingle(applicationObject, menuCommand);

            CommonHandlers.ActionBeforeQueryStatusSolutionExplorerSingleItemContainsProject(applicationObject, menuCommand);
        }
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleCheckPluginStepsRequiredComponents(connectionData);
 }
示例#12
0
 protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
 {
     CommonHandlers.ActionBeforeQueryStatusActiveDocumentJavaScriptHasLinkedSystemForm(applicationObject, menuCommand);
 }
示例#13
0
 protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
 {
     CommonHandlers.ActiveSolutionExplorerProjectSingle(applicationObject, menuCommand);
 }
示例#14
0
 public virtual void OnBackstabConnectedToServer(ConnectionData data)
 {
     ;
 }
示例#15
0
 public override void OnBackstabConnectedToServer(ConnectionData data)
 {
     serverData = data;
 }
示例#16
0
 protected override void CommandBeforeQueryStatus(DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
 {
     _sourceSelectedProjects.CommandBeforeQueryStatus(applicationObject, menuCommand);
 }
        private static string GetAttributeStringInternal(Entity entity, string key, Func <FormattedValueCollection, string, object, ConnectionData, string> getterString, ConnectionData connectionData)
        {
            if (!entity.Attributes.Contains(key))
            {
                return(string.Empty);
            }

            var value = entity.Attributes[key];

            if (value is EntityReference)
            {
                var reference = (EntityReference)value;

                if (reference.Id == Guid.Empty)
                {
                    entity.Attributes.Remove(key);
                    return(string.Empty);
                }
            }

            if (value == null)
            {
                return(string.Empty);
            }

            return(getterString(entity.FormattedValues, key, value, connectionData));
        }
示例#18
0
 private void OnConnectionChanged(ConnectionData connectionData)
 {
     _eventAggregator.Publish(new ConnectionChangedEvent(connectionData));
 }
示例#19
0
        protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
        {
            var selectedProjects = _sourceSelectedProjects.GetSelectedProjects(helper).ToList();

            helper.HandlePluginAssemblyBuildProjectUpdateCommand(connectionData, false, selectedProjects);
        }
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleOpenSystemUsersExplorer(connectionData);
 }
示例#21
0
 protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
 {
     CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsCSharp(applicationObject, menuCommand);
 }
示例#22
0
        protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
        {
            List <SelectedFile> selectedFiles = helper.GetOpenedDocuments(FileOperations.SupportsCSharpType).ToList();

            helper.HandleUpdateEntityMetadataFileCSharpProxyClass(connectionData, selectedFiles, false);
        }
        private void AnalyzeConnections(ConnectionData[] connections)
        {
            _receivedSinceLastRun = 0;
            _sentSinceLastRun = 0;
            _pendingSendOnLastRun = 0;
            _inSendOnLastRun = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            Console.WriteLine("# Total connections: {0,3}. Out: {1,8:f1}kb/s  In: {2,8:f1}kb.s  Pending Send: {3}  In Send: {4}  Pending Received: {5}",
                connections.Length,
                _sentSinceLastRun / 1024.0 / _runPeriod,
                _receivedSinceLastRun / 1024.0 / _runPeriod,
                _pendingSendOnLastRun,
                _inSendOnLastRun,
                _pendingReceivedOnLastRun);
        }
 public static string GetAttributeString(Entity entity, string key, ConnectionData connectionData = null)
 {
     return(GetAttributeStringInternal(entity, key, GetValueStringFull, connectionData));
 }
示例#25
0
        void OnServiceResolved(object o, ServiceInfoArgs args)
        {
            ConnectionData cd = new ConnectionData ();
            cd.Name = String.Format ("{0} ({1})", args.Service.Name, args.Service.Address);
            cd.Host = args.Service.Address.ToString ();
            cd.Port = args.Service.Port;
            cd.UserName = "";
            cd.Pass = "";
            cd.DontSavePassword = false;
            cd.ServerType = Util.GetServerType ("Generic LDAP server");
            cd.Dynamic = true;

            Log.Debug ("Found LDAP service {0} on {1} port {2}",
                args.Service.Name, args.Service.Address, args.Service.Port);

            if (args.Service.Port == 636)
                cd.Encryption = EncryptionType.SSL;

            Connection conn = new Connection (cd);

            if (Found != null) {
                FoundServiceEventArgs fargs = new FoundServiceEventArgs ();
                fargs.FoundConnection = conn;
                Found (this, fargs);
            }
        }
 public static string GetAttributeStringShortEntityReferenceAndPicklist(Entity entity, string key, ConnectionData connectionData = null)
 {
     return(GetAttributeStringInternal(entity, key, GetValueStringShortEntityReferenceAndPicklist, connectionData));
 }
示例#27
0
        //        private void ProfileConnect ()
        //        {
        //            LdapServer server = null;
        //            ConnectionProfile cp = GetSelectedProfile ();
        //
        //            if (cp.Host == null) {
        //
        //                string	msg = Mono.Unix.Catalog.GetString (
        //                    "No profile selected");
        //
        //                HIGMessageDialog dialog = new HIGMessageDialog (
        //                    connectionDialog,
        //                    0,
        //                    Gtk.MessageType.Error,
        //                    Gtk.ButtonsType.Ok,
        //                    "Profile error",
        //                    msg);
        //
        //                dialog.Run ();
        //                dialog.Destroy ();
        //
        //                return;
        //            }
        //
        //            if (cp.LdapRoot == "") {
        //
        //                server = new LdapServer (cp.Host, cp.Port, cp.ServerType);
        //
        //            } else {
        //
        //                server = new LdapServer (cp.Host, cp.Port,
        //                         cp.LdapRoot,
        //                         cp.ServerType);
        //            }
        //
        //            server.ProfileName = cp.Name;
        //            encryption = cp.Encryption;
        //
        //            if (cp.DontSavePassword) {
        //
        //                LoginDialog ld = new LoginDialog (
        //                    Mono.Unix.Catalog.GetString ("Enter your password"),
        //                    cp.User);
        //
        //                ld.Run ();
        //
        //                if (ld.UserPass != null)
        //                    DoConnect (server, ld.UserName, ld.UserPass);
        //
        //            } else {
        //
        //                DoConnect (server, cp.User, cp.Pass);
        //            }
        //        }
        public void OnConnectClicked(object o, EventArgs args)
        {
            TreeIter iter;

            if (!serverTypeComboBox.GetActiveIter (out iter))
                return;

            string serverType = (string) serverTypeComboBox.Model.GetValue (iter, 0);

            ConnectionData cd = new ConnectionData ();
            cd.Host = hostEntry.Text;
            cd.Port = int.Parse (portEntry.Text);
            cd.UserName = userEntry.Text;
            cd.Pass = passEntry.Text;
            cd.DirectoryRoot = ldapBaseEntry.Text;
            cd.ServerType = Util.GetServerType (serverType);
            cd.DontSavePassword = false;
            cd.Encryption = encryption;

            if (saveProfileButton.Active) {
                cd.Name = profileNameEntry.Text;
                cd.Dynamic = false;
            } else {
                cd.Name = String.Format ("{0}:{1}", cd.Host, cd.Port);
                cd.Dynamic = true;
            }

            Connection conn = new Connection (cd);
            Global.Connections [cd.Name] = conn;
        }
        private static string GetValueStringFull(FormattedValueCollection formattedValues, string key, object value, ConnectionData connectionData)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            if (value is EntityReference entityReference)
            {
                StringBuilder result = new StringBuilder();

                if (!string.IsNullOrEmpty(entityReference.Name))
                {
                    result.AppendFormat("{0} - ", entityReference.Name);
                }

                result.AppendFormat("{0} - {1}", entityReference.LogicalName, entityReference.Id.ToString());

                if (connectionData != null)
                {
                    var url = connectionData.GetEntityInstanceUrl(entityReference.LogicalName, entityReference.Id);

                    if (!string.IsNullOrEmpty(url))
                    {
                        result.AppendFormat(" - {0}", url);
                    }
                }

                return(result.ToString());
            }

            if (value is BooleanManagedProperty booleanManaged)
            {
                return(string.Format("{0,-5}        CanBeChanged = {1,-5}", booleanManaged.Value, booleanManaged.CanBeChanged));
            }

            if (value is OptionSetValue optionSetValue)
            {
                return(optionSetValue.Value.ToString() + (formattedValues.ContainsKey(key) ? string.Format(" - {0}", formattedValues[key]) : string.Empty));
            }

            if (value is OptionSetValueCollection valueOptionSetValueCollection)
            {
                string valuesString = valueOptionSetValueCollection.Any() ? string.Join(",", valueOptionSetValueCollection.Select(o => o.Value).OrderBy(o => o)) : "none";

                return(valuesString + (formattedValues.ContainsKey(key) ? string.Format(" - {0}", formattedValues[key]) : string.Empty));
            }

            if (value is Money money)
            {
                return(money.Value.ToString());
            }

            if (value is DateTime dateTime)
            {
                return(dateTime.ToLocalTime().ToString("G", System.Globalization.CultureInfo.CurrentCulture));
            }

            if (value is AliasedValue aliasedValue)
            {
                return(GetValueStringFull(formattedValues, key, aliasedValue.Value, connectionData));
            }

            if (value is EntityCollection entityCollection)
            {
                StringBuilder result = new StringBuilder();

                result.AppendFormat("EnitityCollection {0}: {1}", entityCollection.EntityName, (entityCollection.Entities?.Count).GetValueOrDefault()).AppendLine();

                foreach (var item in entityCollection.Entities)
                {
                    string entityDesc = GetEntityDescription(item, connectionData);

                    if (!string.IsNullOrEmpty(entityDesc))
                    {
                        var split = entityDesc.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (var str in split)
                        {
                            result.AppendLine(_defaultTabSpacer + _defaultTabSpacer + str);
                        }
                    }
                }

                return(result.ToString());
            }

            return(value.ToString());
        }
示例#29
0
        /// <summary>
        /// This is the Connetion creation function, this function should enlist in the
        /// current transaction as well reusing the same connection for all the call
        /// inside a global transaction to consume less resources.
        /// </summary>
        /// <param name="connectionName"></param>
        /// <returns></returns>
        internal static GlobalTransactionManager.TransactionToken CreateConnection(string connectionName)
        {
            ConnectionData newConnData = null;
            if (GlobalTransactionManager.IsInTransaction)
            {
                //We are in a transaction, check if at current connection stack level there is  a connection data.
                Object connData = GlobalTransactionManager.TransactionContext.Get(GetKeyFromConnName(connectionName));
                if (null != connData)
                {
                    //We already created the connection for this database in this transaction.
                    return GlobalTransactionManager.Enlist(DoNothing);
                }
                //There is not a transaction in the current transaction stack level, are we in nested transaction?
                if (GlobalTransactionManager.TransactionsCount > 1)
                {
                    //The only connection data valid is the one at the first level, lets check if it is present.
                    connData = GlobalTransactionManager.TransactionContext.Get(GetKeyFromConnName(connectionName), 0);
                    if (null == connData)
                    {
                        //We never created the connection data
                        newConnData = new ConnectionData(connectionName);
                        GlobalTransactionManager.TransactionContext.Set(GetKeyFromConnName(connectionName), newConnData, 0);
                        GlobalTransactionManager.Enlist(newConnData.CloseConnection, 0);
                    }
                    else
                    {
                        newConnData = (ConnectionData)connData;
                    }

                    GlobalTransactionManager.TransactionToken lasttoken = null;
                    //Now we have the connection data, we need to store this connection data in each connection that is active and
                    //that still not have start a transaction
                    for (Int32 Ix = 1; Ix < GlobalTransactionManager.TransactionsCount; ++Ix)
                    {
                        if (GlobalTransactionManager.TransactionContext.Get(GetKeyFromConnName(connectionName), Ix) == null)
                        {
                            //In this step of the stack there is no ConnectionData, store and increase the transaction
                            newConnData.BeginNestedTransaction();
                            lasttoken = GlobalTransactionManager.Enlist(newConnData.CloseConnection, Ix);
                            lasttoken.SetInTransactionContext(GetKeyFromConnName(connectionName), newConnData);
                        }
                    }
                    //Return the last token, the one corresponding to the current transaction level.
                    return lasttoken;
                }
            }

            //We are not in nested transaction and there is not connection data, create for the first time
            newConnData = new ConnectionData(connectionName);
            GlobalTransactionManager.TransactionToken token =
                GlobalTransactionManager.Enlist(newConnData.CloseConnection);
            token.SetInTransactionContext(GetKeyFromConnName(connectionName), newConnData);
            return token;
        }
 public static Task ExportEntityDescriptionAsync(string filePath, Entity entity, ConnectionData connectionData = null)
 {
     return(Task.Run(() => ExportEntityDescription(filePath, entity, connectionData)));
 }
示例#31
0
        protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
        {
            var project = helper.GetSelectedProject();

            helper.HandleRegisterPluginAssemblyCommand(connectionData, project);
        }
        private static void ExportEntityDescription(string filePath, Entity entity, ConnectionData connectionData)
        {
            string content = GetEntityDescription(entity, connectionData);

            File.WriteAllText(filePath, content, new UTF8Encoding(false));
        }
示例#33
0
        private async Task OnPacketReceived(Packet msg)
        {
            try
            {
                switch (msg.PacketType)
                {
                case PacketType.CONNACK:
                    Log($"[{_instaApi.GetLoggedUser().UserName}] " + "Received CONNACK");
                    ConnectionData.UpdateAuth(((FbnsConnAckPacket)msg).Authentication);
                    await RegisterMqttClient();

                    break;

                case PacketType.PUBLISH:
                    Log($"[{_instaApi.GetLoggedUser().UserName}] " + "Received PUBLISH");
                    var publishPacket = (PublishPacket)msg;
                    if (publishPacket.Payload == null)
                    {
                        throw new Exception($"{nameof(PushClient)}: Publish packet received but payload is null");
                    }
                    if (publishPacket.QualityOfService == QualityOfService.AtLeastOnce)
                    {
                        await FbnsPacketEncoder.EncodePacket(PubAckPacket.InResponseTo(publishPacket), _outboundWriter);
                    }

                    var payload = DecompressPayload(publishPacket.Payload);
                    var json    = Encoding.UTF8.GetString(payload);
                    Log($"[{_instaApi.GetLoggedUser().UserName}] " + $"MQTT json: {json}");
                    switch (Enum.Parse(typeof(TopicIds), publishPacket.TopicName))
                    {
                    case TopicIds.Message:
                        var message = JsonConvert.DeserializeObject <PushReceivedEventArgs>(json);
                        message.Json     = json;
                        message.InstaApi = _instaApi;
                        MessageReceived?.Invoke(this, message);
                        break;

                    case TopicIds.RegResp:
                        await OnRegisterResponse(json);

                        StartKeepAliveLoop();
                        break;

                    default:
                        Log($"[{_instaApi.GetLoggedUser().UserName}] " + $"Unknown topic received: {publishPacket.TopicName}");
                        break;
                    }

                    break;

                case PacketType.PUBACK:
                    Log($"[{_instaApi.GetLoggedUser().UserName}] " + "Received PUBACK");
                    _waitingForPubAck = false;
                    break;

                // todo: PingResp never arrives even though data was received. Decoder problem?
                case PacketType.PINGRESP:
                    Log($"[{_instaApi.GetLoggedUser().UserName}] " + "Received PINGRESP");
                    break;

                default: return;
                    //throw new NotSupportedException($"Packet type {msg.PacketType} is not supported.");
                }
            }
            catch (Exception)
            {
                Shutdown();
            }
        }
 public static Task <string> GetEntityDescriptionAsync(Entity entity, ConnectionData connectionData = null)
 {
     return(Task.Run(() => GetEntityDescription(entity, connectionData)));
 }
示例#35
0
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleCheckManagedEntities(connectionData);
 }
        private static string GetValueStringShortEntityReference(FormattedValueCollection formattedValues, string key, object value, ConnectionData connectionData)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            if (value is EntityReference entityReference)
            {
                if (!string.IsNullOrEmpty(entityReference.Name))
                {
                    return(entityReference.Name);
                }
                else
                {
                    return(string.Format("{0} - {1}", entityReference.LogicalName, entityReference.Id.ToString()));
                }
            }

            if (value is BooleanManagedProperty booleanManagedboolean)
            {
                return(string.Format("{0,-5}    CanBeChanged = {1,-5}", booleanManagedboolean.Value, booleanManagedboolean.CanBeChanged));
            }

            if (value is OptionSetValue optionSetValue)
            {
                return(optionSetValue.Value.ToString() + (formattedValues.ContainsKey(key) ? string.Format(" - {0}", formattedValues[key]) : string.Empty));
            }

            if (value is OptionSetValueCollection valueOptionSetValueCollection)
            {
                string valuesString = valueOptionSetValueCollection.Any() ? string.Join(",", valueOptionSetValueCollection.Select(o => o.Value).OrderBy(o => o)) : "none";

                return(valuesString + (formattedValues.ContainsKey(key) ? string.Format(" - {0}", formattedValues[key]) : string.Empty));
            }

            if (value is Money money)
            {
                return(money.Value.ToString());
            }

            if (value is DateTime dateTime)
            {
                return(dateTime.ToLocalTime().ToString("G", System.Globalization.CultureInfo.CurrentCulture));
            }

            if (value is AliasedValue aliasedValue)
            {
                return(GetValueStringShortEntityReference(formattedValues, key, aliasedValue.Value, connectionData));
            }

            if (value is EntityCollection entityCollection)
            {
                return(string.Format("EnitityCollection {0}: {1}", entityCollection.EntityName, (entityCollection.Entities?.Count).GetValueOrDefault()));
            }

            return(value.ToString());
        }
 public override void OnBackstabConnectedToServer(ConnectionData data)
 {
     boxMessage = "Connected to " +data.address;
 }
        public static DataTable ConvertEntityCollectionToDataTable(ConnectionData connectionData, EntityCollection entityCollection, out Dictionary <string, string> columnMapping)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add(ColumnOriginalEntity, typeof(Entity));

            columnMapping = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var entity in entityCollection.Entities)
            {
                DataRow row = dataTable.NewRow();

                row[ColumnOriginalEntity] = entity;

                foreach (string attributeName in entity.Attributes.Keys)
                {
                    var value = entity.Attributes[attributeName];

                    if (value == null || EntityDescriptionHandler.GetUnderlyingValue(value) == null)
                    {
                        continue;
                    }

                    string entityPrimaryIdAttribute = connectionData.GetEntityPrimaryIdAttribute(entity.LogicalName);

                    if (value is Guid idValue &&
                        string.Equals(entityPrimaryIdAttribute, attributeName, StringComparison.InvariantCultureIgnoreCase)
                        )
                    {
                        value = new PrimaryGuidView(connectionData, entity.LogicalName, idValue);
                    }

                    string columnName = string.Format("{0}___{1}", entity.LogicalName, attributeName.Replace(".", "_"));

                    if (value is AliasedValue aliasedValue)
                    {
                        columnName = string.Format("{0}___{1}___{2}", attributeName.Replace(".", "_"), aliasedValue.EntityLogicalName, aliasedValue.AttributeLogicalName);

                        string aliasedValuePrimaryIdAttribute = connectionData.GetEntityPrimaryIdAttribute(aliasedValue.EntityLogicalName);

                        if (aliasedValue.Value is Guid refIdValue &&
                            string.Equals(aliasedValuePrimaryIdAttribute, aliasedValue.AttributeLogicalName, StringComparison.InvariantCultureIgnoreCase)
                            )
                        {
                            value = new PrimaryGuidView(connectionData, aliasedValue.EntityLogicalName, refIdValue);
                        }
                    }

                    value = EntityDescriptionHandler.GetUnderlyingValue(value);

                    if (value is EntityReference entityReference)
                    {
                        value = new EntityReferenceView(connectionData, entityReference.LogicalName, entityReference.Id, entityReference.Name);
                    }

                    if (value is Money money)
                    {
                        value = money.Value;
                    }

                    if (value is DateTime dateTime)
                    {
                        value = dateTime.ToLocalTime();
                    }

                    if (value is OptionSetValue optionSetValue)
                    {
                        value = (entity.FormattedValues != null && entity.FormattedValues.ContainsKey(attributeName) ? string.Format("{0} - ", entity.FormattedValues[attributeName]) : string.Empty) + optionSetValue.Value.ToString();
                    }

                    if (value is OptionSetValueCollection valueOptionSetValueCollection)
                    {
                        string valuesString = valueOptionSetValueCollection.Any() ? string.Join(",", valueOptionSetValueCollection.Select(o => o.Value).OrderBy(o => o)) : "none";

                        value = (entity.FormattedValues != null && entity.FormattedValues.ContainsKey(attributeName) ? string.Format("{0} - ", entity.FormattedValues[attributeName]) : string.Empty) + valuesString;
                    }

                    if (value is BooleanManagedProperty booleanManagedProperty)
                    {
                        value = string.Format("{0,-5}        CanBeChanged = {1,-5}", booleanManagedProperty.Value, booleanManagedProperty.CanBeChanged);
                    }

                    if (value is EntityCollection valueEntityCollection)
                    {
                        value = string.Format("EnitityCollection {0}: {1}", valueEntityCollection.EntityName, (valueEntityCollection.Entities?.Count).GetValueOrDefault());
                    }

                    if (dataTable.Columns.IndexOf(columnName) == -1)
                    {
                        if (!columnMapping.ContainsKey(attributeName))
                        {
                            columnMapping.Add(attributeName, columnName);
                        }

                        dataTable.Columns.Add(columnName, value.GetType());
                    }

                    row[columnName] = value;
                }

                dataTable.Rows.Add(row);
            }

            return(dataTable);
        }
        private void AnalyzeConnection(ConnectionData connectionData)
        {
            var connection = connectionData.Connection;
            if (!connection.IsInitialized)
                return;

            if (connection.IsFaulted)
            {
                Console.Error.WriteLine("# {0} is faulted", connection);
                return;
            }

            UpdateStatistics(connectionData);

            CheckPendingReceived(connection);
            CheckPendingSend(connection);
            CheckMissingSendCallback(connectionData, connection);
            CheckMissingReceiveCallback(connectionData, connection);
            CheckReceiveTimeout(connectionData, connection);
        }
        public static List <string> GetColumnsFromFetch(ConnectionData connectionData, XElement fetchXml)
        {
            var hashColumns = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            var result      = new List <string>();

            var linkElements = fetchXml.DescendantsAndSelf().Where(n => IsLinkElement(n)).ToList();

            {
                var entityElements = fetchXml.DescendantsAndSelf().Where(IsAttributeOrAllElement).ToList();

                foreach (var attributeNode in entityElements)
                {
                    if (IsAttributeElement(attributeNode))
                    {
                        var attrAlias = attributeNode.Attribute("alias");

                        if (attrAlias != null && !string.IsNullOrEmpty(attrAlias.Value))
                        {
                            if (hashColumns.Add(attrAlias.Value))
                            {
                                result.Add(attrAlias.Value);
                            }
                        }
                        else
                        {
                            string name = attributeNode.Attribute("name").Value;

                            var parentElement = attributeNode.Ancestors().FirstOrDefault(IsEntityOrLinkElement);

                            if (parentElement != null)
                            {
                                var parentAlias = parentElement.Attribute("alias");

                                if (parentAlias != null && !string.IsNullOrEmpty(parentAlias.Value))
                                {
                                    name = parentAlias.Value + "." + name;
                                }
                                else if (IsLinkElement(parentElement))
                                {
                                    if (linkElements.Contains(parentElement))
                                    {
                                        var index = linkElements.IndexOf(parentElement) + 1;

                                        name = parentElement.Attribute("name")?.Value + index.ToString() + "." + name;
                                    }
                                }
                            }

                            if (hashColumns.Add(name))
                            {
                                result.Add(name);
                            }
                        }
                    }
                    else if (IsAllAttributesElement(attributeNode))
                    {
                        var parentElement = attributeNode.Ancestors().FirstOrDefault(IsEntityOrLinkElement);

                        if (parentElement != null)
                        {
                            var parentAlias      = parentElement.Attribute("alias");
                            var parentEntityName = parentElement.Attribute("name");

                            string parentPrefixName = string.Empty;

                            if (parentAlias != null && !string.IsNullOrEmpty(parentAlias.Value))
                            {
                                parentPrefixName = parentAlias.Value + ".";
                            }
                            else if (IsLinkElement(parentElement))
                            {
                                if (linkElements.Contains(parentElement))
                                {
                                    var index = linkElements.IndexOf(parentElement) + 1;

                                    parentPrefixName = parentElement.Attribute("name")?.Value + index.ToString();
                                }
                            }

                            var intellisenseData = connectionData.EntitiesIntellisenseData;

                            if (intellisenseData != null &&
                                intellisenseData.Entities != null &&
                                intellisenseData.Entities.ContainsKey(parentEntityName.Value) &&
                                intellisenseData.Entities[parentEntityName.Value].Attributes != null
                                )
                            {
                                foreach (var attrName in intellisenseData.Entities[parentEntityName.Value].Attributes.Keys.OrderBy(s => s))
                                {
                                    string name = parentPrefixName + attrName;

                                    if (hashColumns.Add(name))
                                    {
                                        result.Add(name);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
 private static void CheckReceiveTimeout(ConnectionData connectionData, IMonitoredTcpConnection connection)
 {
     DateTime? lastReceiveStarted = connection.LastReceiveStarted;
     if (lastReceiveStarted == null)
         return;
     int sinceLastReceive = (int)(DateTime.Now - lastReceiveStarted.GetValueOrDefault()).TotalMilliseconds;
     if (sinceLastReceive > 10000)
     {
         Console.Error.WriteLine(
             "# {0} {1}ms since last Receive started. No data receive din 10000ms. TIMEOUT DETECTED",
             connection, sinceLastReceive);
     }
 }
        private ConnectionData GetFirstAvailableConn()
        {
            ConnectionData cd = new ConnectionData();
            if (_connList.Count(x => x.Value.inUse == false) > 0)
            {
                lock (_mutex)
                {
                    if (_connList.Count(x => x.Value.inUse == false) > 0)
                    {
                        string key = _connList.First(x => x.Value.inUse == false).Key;
                        cd = _connList[key];
                        cd.inUse = true;
                        cd.lastUse = DateTime.Now;
                        _connList[key] = cd;

                        System.Diagnostics.Debug.WriteLine("Get available (" + cd.id + ") at: " + DateTime.Now.ToString("HH:mm:ss.ffff"));
                        System.Diagnostics.Debug.WriteLine("Total of: " + _connList.Count());
                    }
                }
            }
            return cd;
        }
示例#43
0
 public virtual void OnBackstabClientConnected(ConnectionData data)
 {
     ;
 }
示例#44
0
        protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
        {
            List <SelectedFile> selectedFiles = helper.GetSelectedFilesInSolutionExplorer(FileOperations.SupportsCSharpType, false).ToList();

            helper.HandleCSharpGlobalOptionSetsFileUpdateSchema(connectionData, selectedFiles, false);
        }
示例#45
0
 //webplayer
 public void connect ()
 {
     if (Application.isWebPlayer) {
         ConnectionData data = new ConnectionData (gameVersionGuid);
         string json = getJsonString (data);
         //logMessage(MessageLevel.DEFAULT, "RedMetricsManager::connect will rmConnect json={0}", json);
         Application.ExternalCall ("rmConnect", json);
     }
     //TODO treat answer by RedMetrics server by executeAndClearAllWaitingEvents so that all waiting events can be sent now that there's a user id
 }
示例#46
0
文件: Util.cs 项目: MrJoe/lat
        static Connection ParseV1Profile(XmlElement profileElement)
        {
            EncryptionType e = EncryptionType.None;
            bool savePassword = false;

            string encryption = profileElement.GetAttribute ("encryption");
            if (encryption != null) {
                if (encryption.ToLower() == "ssl")
                    e = EncryptionType.SSL;
                else if (encryption.ToLower() == "tls")
                    e = EncryptionType.TLS;
            }

            string sp = profileElement.GetAttribute ("save_password");
            if (sp != null) {
                try { savePassword = bool.Parse (sp); }
                catch { savePassword = false; }
            }

            ConnectionData data = new ConnectionData (
                    profileElement.GetAttribute ("name"),
                    profileElement.GetAttribute ("host"),
                    int.Parse (profileElement.GetAttribute ("port")),
                    profileElement.GetAttribute ("base"),
                    profileElement.GetAttribute ("user"),
                    savePassword,
                    e,
                    Util.GetServerType (profileElement.GetAttribute ("server_type")),
                    false);

            Connection conn = new Connection (data);
            conn.SetDefaultAttributeViewers ();
            conn.SetDefaultServerViews ();

            return conn;
        }
        private TcpStats AnalyzeConnections(ConnectionData[] connections, TimeSpan measurePeriod)
        {
            _receivedSinceLastRun = 0;
            _sentSinceLastRun = 0;
            _pendingSendOnLastRun = 0;
            _inSendOnLastRun = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            var stats = new TcpStats(connections.Length,
                                     _sentTotal,
                                     _receivedTotal,
                                     _sentSinceLastRun,
                                     _receivedSinceLastRun,
                                     _pendingSendOnLastRun,
                                     _inSendOnLastRun,
                                     _pendingReceivedOnLastRun,
                                     measurePeriod);


            Log.Trace("# Total connections: {0,3}. Out: {1:8}  In: {2:8}  Pending Send: {3}  " +
                      "In Send: {4}  Pending Received: {5} Measure Time: {6}",
                stats.Connections,
                stats.SendingSpeed,
                stats.ReceivingSpeed,
                stats.PendingSend,
                stats.InSend,
                stats.PendingSend,
                stats.MeasureTimeFriendly);

            return stats;
        }
示例#48
0
        private void UpdateStatistics(ConnectionData connectionData)
        {
            var connection = connectionData.Connection;
            long totalBytesSent = connection.TotalBytesSent;
            long totalBytesReceived = connection.TotalBytesReceived;
            long pendingSend = connection.PendingSendBytes;
            long inSend = connection.InSendBytes;
            long pendingReceived = connection.PendingReceivedBytes;

            _sentSinceLastRun += totalBytesSent - connectionData.LastTotalBytesSent;
            _receivedSinceLastRun += totalBytesReceived - connectionData.LastTotalBytesReceived;

            _sentTotal += _sentSinceLastRun;
            _receivedTotal += _sentSinceLastRun;

            _pendingSendOnLastRun += pendingSend;
            _inSendOnLastRun += inSend;
            _pendingReceivedOnLastRun = pendingReceived;

            connectionData.LastTotalBytesSent = totalBytesSent;
            connectionData.LastTotalBytesReceived = totalBytesReceived;
        }
示例#49
0
        private void worker()
        {
            string[] files = Directory.GetFiles(_path);

            foreach (string file in files)
            {
                if (!file.EndsWith(".pcap"))
                {
                    continue;
                }

                _connectionDatas.Clear();

                PcapOfflineDevice device = SharpPcap.GetPcapOfflineDevice(file);
                device.PcapOpen();

                Packet packet;
                do
                {
                    packet = device.PcapGetNextPacket();

                    TCPPacket tcpPacket = packet as TCPPacket;
                    if (tcpPacket == null)
                    {
                        continue;
                    }

                    if (!tcpPacket.SourceAddress.Equals(source) || !tcpPacket.DestinationAddress.Equals(destination))
                    {
                        continue;
                    }

                    ConnectionData connectionData;
                    if (!_connectionDatas.TryGetValue(getPacketId(tcpPacket), out connectionData))
                    {
                        connectionData = new ConnectionData();
                        _connectionDatas.Add(getPacketId(tcpPacket), connectionData);
                    }

                    //Logger.WriteConsole("Got Packet: " + packet);)
                    if (tcpPacket.Data.Length > 0)
                    {
                        if (tcpPacket.SequenceNumber != connectionData.Sequence && connectionData.Sequence != -1)
                        {
                            connectionData.PacketCache.Add(tcpPacket);
                        }
                        else if (connectionData.Sequence == -1 || connectionData.Sequence == tcpPacket.SequenceNumber)
                        {
                            sendBytes(tcpPacket.Data);
                            connectionData.Sequence = tcpPacket.SequenceNumber + tcpPacket.PayloadDataLength;

                            List<TCPPacket> remove = new List<TCPPacket>();
                            foreach (TCPPacket outOfOrderPacket in connectionData.PacketCache)
                            {
                                if (connectionData.Sequence == outOfOrderPacket.SequenceNumber)
                                {
                                    remove.Add(outOfOrderPacket);
                                    sendBytes(outOfOrderPacket.Data);
                                    connectionData.Sequence = outOfOrderPacket.SequenceNumber + outOfOrderPacket.PayloadDataLength;
                                }
                            }

                            foreach (TCPPacket tcpPacket1 in remove)
                            {
                                connectionData.PacketCache.Remove(tcpPacket1);
                            }
                        }

                    }
                } while (packet != null);

                foreach (KeyValuePair<string, ConnectionData> connectionData in _connectionDatas)
                {
                    Logger.Log("Remaining packets: " + connectionData.Value.PacketCache.Count);
                    foreach (TCPPacket tcpPacket in connectionData.Value.PacketCache)
                    {
                        Logger.WriteConsole("SN: " + tcpPacket.SequenceNumber);
                    }
                }
            }
        }
示例#50
0
        /// <summary>
        /// Performs the database scripts execution against the specified server/ database settings
        /// </summary>
        /// <param name="serverName">Name of the SQL server to target</param>
        /// <param name="overrides">List of database override settings to use in execution</param>
        /// <returns></returns>
        internal async Task <int> RunDatabaseBuild()
        {
            this.returnValue = (int)RunnerReturn.BuildResultInconclusive;

            ConnectionData   connData         = null;
            BackgroundWorker bg               = null;
            DoWorkEventArgs  e                = null;
            SqlBuildRunData  runData          = new SqlBuildRunData();
            string           targetDatabase   = overrides[0].OverrideDbTarget;
            string           loggingDirectory = Path.Combine(ThreadedExecution.WorkingDirectory, server, targetDatabase);

            try
            {
                //Start setting properties on the object that contains the run configuration data.
                runData.BuildType = "Other";
                if (!string.IsNullOrEmpty(cmdArgs.Description))
                {
                    runData.BuildDescription = cmdArgs.Description;
                }
                else
                {
                    runData.BuildDescription = "Threaded Multi-Database. Run ID:" + ThreadedExecution.RunID;
                }

                runData.IsTrial                 = this.isTrial;
                runData.RunScriptOnly           = false;
                runData.TargetDatabaseOverrides = overrides;
                runData.Server          = this.server;
                runData.IsTransactional = cmdArgs.Transactional;
                if (this.cmdArgs.LogToDatabaseName.Length > 0)
                {
                    runData.LogToDatabaseName = this.cmdArgs.LogToDatabaseName;
                }

                runData.PlatinumDacPacFileName = cmdArgs.DacPacArgs.PlatinumDacpac;
                runData.BuildRevision          = cmdArgs.BuildRevision;
                runData.DefaultScriptTimeout   = cmdArgs.DefaultScriptTimeout;
                runData.AllowObjectDelete      = cmdArgs.AllowObjectDelete;


                //Initilize the logging directory for this run
                if (!Directory.Exists(loggingDirectory))
                {
                    Directory.CreateDirectory(loggingDirectory);
                }

                if (forceCustomDacpac)
                {
                    runData.ForceCustomDacpac = true;
                    //This will set the BuildData and BuildFileName and ProjectFileName properties on runData
                    var status = DacPacHelper.UpdateBuildRunDataForDacPacSync(ref runData, server, targetDatabase, this.authType, this.username, this.password, loggingDirectory, cmdArgs.BuildRevision, cmdArgs.DefaultScriptTimeout, cmdArgs.AllowObjectDelete);
                    switch (status)
                    {
                    case DacpacDeltasStatus.Success:
                        //nothing to do
                        break;

                    case DacpacDeltasStatus.InSync:
                    case DacpacDeltasStatus.OnlyPostDeployment:
                        log.LogInformation($"Target database {targetDatabase} is already in sync with {cmdArgs.DacPacArgs.PlatinumDacpac}. Nothing to do!");
                        this.returnValue = (int)RunnerReturn.DacpacDatabasesInSync;
                        break;

                    default:
                        log.LogError($"Error creating custom dacpac and scripts for {targetDatabase}. No update was performed");
                        this.returnValue = (int)RunnerReturn.PackageCreationError;
                        return((int)RunnerReturn.PackageCreationError);;
                    }
                }
                else
                {
                    runData.ForceCustomDacpac = false;
                    //Get a full copy of the build data to work with (avoid threading sync issues)
                    SqlSyncBuildData buildData = new SqlSyncBuildData();

                    string xml = "<?xml version=\"1.0\" standalone=\"yes\"?>\r\n" + ThreadedExecution.BuildData.GetXml();
                    using (StringReader sr = new StringReader(xml))
                    {
                        buildData.ReadXml(sr);
                    }
                    //Clear out any existing ComittedScript data.. just log what is relevent to this run.
                    buildData.CommittedScript.Clear();


                    runData.BuildData       = buildData;
                    runData.ProjectFileName = Path.Combine(loggingDirectory, Path.GetFileName(ThreadedExecution.ProjectFileName));
                    runData.BuildFileName   = ThreadedExecution.BuildZipFileName;
                }



                //Create a connection object.. all we need is the server here, the DB will be filled in at execution time
                connData = new ConnectionData(server, "");
                if (this.cmdArgs.AuthenticationArgs.UserName.Length > 0 && this.cmdArgs.AuthenticationArgs.Password.Length > 0)
                {
                    connData.UserId   = cmdArgs.AuthenticationArgs.UserName;
                    connData.Password = cmdArgs.AuthenticationArgs.Password;
                }
                connData.AuthenticationType = this.cmdArgs.AuthenticationArgs.AuthenticationType;

                //Set the log file name
                string logFile = Path.Combine(loggingDirectory, "ExecutionLog.log");

                //Create the objects that will handle the event communication back.
                bg = new BackgroundWorker();
                //bg.ProgressChanged += Bg_ProgressChanged;
                bg.WorkerReportsProgress = true;
                e = new DoWorkEventArgs(null);
            }
            catch (Exception exe)
            {
                log.LogError(exe, $"Error Initializing run for {this.TargetTag}");
                WriteErrorLog(loggingDirectory, exe.ToString());
                this.returnValue = (int)ExecutionReturn.RunInitializationError;
                return((int)ExecutionReturn.RunInitializationError);;
            }

            log.LogDebug("Initializing run for " + this.TargetTag + ". Starting \"ProcessBuild\"");

            try
            {
                //Initilize the run helper object and kick it off.
                SqlBuildHelper helper = new SqlBuildHelper(connData, true, string.Empty, cmdArgs.Transactional); //don't need an "external" log for this, it's all external!
                helper.BuildCommittedEvent              += new BuildCommittedEventHandler(helper_BuildCommittedEvent);
                helper.BuildErrorRollBackEvent          += new EventHandler(helper_BuildErrorRollBackEvent);
                helper.BuildSuccessTrialRolledBackEvent += new EventHandler(helper_BuildSuccessTrialRolledBackEvent);
                await Task.Run(() =>
                {
                    helper.ProcessBuild(runData, bg, e, ThreadedExecution.BatchColl, this.buildRequestedBy, cmdArgs.TimeoutRetryCount);
                });
            }
            catch (Exception exe)
            {
                log.LogError("Error Processing run for " + this.TargetTag, exe);
                WriteErrorLog(loggingDirectory, exe.ToString());
                this.returnValue = (int)ExecutionReturn.ProcessBuildError;
                return((int)ExecutionReturn.ProcessBuildError);;
            }
            return(0);
        }
示例#51
0
        public void OnOkClicked(object o, EventArgs args)
        {
            TreeIter iter;

            if (!serverTypeComboBox.GetActiveIter (out iter))
                return;

            string st = (string) serverTypeComboBox.Model.GetValue (iter, 0);

            ConnectionData data = new ConnectionData ();
            data.Name = profileNameEntry.Text;
            data.Host = hostEntry.Text;
            data.Port = int.Parse (portEntry.Text);
            data.DirectoryRoot = ldapBaseEntry.Text;
            data.UserName = userEntry.Text;
            data.Encryption = encryption;
            data.DontSavePassword = savePasswordButton.Active;
            data.ServerType = Util.GetServerType (st);

            if (data.DontSavePassword)
                data.Pass = "";
            else
                data.Pass = passEntry.Text;

            if (isEdit) {

                Connection c = Global.Connections [data.Name];
                c.Settings = data;

                if (!oldName.Equals (data.Name)) {

                    Global.Connections.Delete (oldName);
                    Global.Connections[data.Name] = c;

                } else {

            //					Global.Connections[data.Name] = c;
                }

            } else {

                Connection c = new Connection (data);
                Global.Connections[data.Name] = c;
            }

            Global.Connections.Save ();
        }
示例#52
0
        protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
        {
            CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRootWithAttribute(
                applicationObject
                , menuCommand
                , Intellisense.Model.IntellisenseContext.IntellisenseContextAttributeFormId
                , out var attribute
                , AbstractDynamicCommandXsdSchemas.RootForm
                );

            if (attribute == null ||
                !Guid.TryParse(attribute.Value, out _)
                )
            {
                menuCommand.Enabled = menuCommand.Visible = false;
            }
        }
        private ConnectionData GetNewConnection()
        {
            ConnectionData d = new ConnectionData();
            d.iconnection = _factory.CreateConnection();
            d.inUse = true;
            d.lastUse = DateTime.Now;
            d.id = Guid.NewGuid().ToString();
            lock (_mutex)
            {
                _connList.Add(d.id, d);
            }

            System.Diagnostics.Debug.WriteLine("Connection Manager created new connection(" + d.id + ") at: " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            System.Diagnostics.Debug.WriteLine("Total of: " + _connList.Count());

            return d;
        }
示例#54
0
        protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand)
        {
            CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRootWithAttribute(applicationObject
                                                                                           , menuCommand
                                                                                           , Intellisense.Model.IntellisenseContext.IntellisenseContextAttributeWebResourceName
                                                                                           , out var attribute
                                                                                           , AbstractDynamicCommandXsdSchemas.WebResourceDependencyXmlRoot
                                                                                           );

            if (attribute == null || string.IsNullOrEmpty(attribute.Value))
            {
                menuCommand.Enabled = menuCommand.Visible = false;
            }
        }
示例#55
0
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleExportReport(connectionData);
 }
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleCheckTeamTemplates(connectionData);
 }
示例#57
0
        private void AnalyzeConnection(ConnectionData connectionData)
        {
            var connection = connectionData.Connection;
            if (!connection.IsInitialized)
                return;

            if (connection.IsFaulted)
            {
                Log.Info("# {0} is faulted", connection);
                return;
            }

            UpdateStatistics(connectionData);

            CheckPendingReceived(connection);
            CheckPendingSend(connection);
            CheckMissingSendCallback(connectionData, connection);
            CheckMissingReceiveCallback(connectionData, connection);
        }
 protected override void CommandAction(DTEHelper helper, ConnectionData connectionData)
 {
     helper.HandleOpenOrganizationDifferenceImageWindow(connectionData);
 }
示例#59
0
        private void CheckMissingSendCallback(ConnectionData connectionData, IMonitoredTcpConnection connection)
        {
            // snapshot all data?
            bool inSend = connection.InSend;
            bool isReadyForSend = connection.IsReadyForSend;
            DateTime? lastSendStarted = connection.LastSendStarted;
            uint inSendBytes = connection.InSendBytes;

            int sinceLastSend = (int)(DateTime.UtcNow - lastSendStarted.GetValueOrDefault()).TotalMilliseconds;
            bool missingSendCallback = inSend && isReadyForSend && sinceLastSend > 500;

            if (missingSendCallback && connectionData.LastMissingSendCallBack)
            {
                // _anySendBlockedOnLastRun = true;
                Log.Error(
                    "# {0} {1}ms since last send started. No completion callback received, but socket status is READY_FOR_SEND. In send: {2}",
                    connection, sinceLastSend, inSendBytes);
            }
            connectionData.LastMissingSendCallBack = missingSendCallback;
        }
示例#60
0
        private void workerThread()
        {
            foreach (string file in _files)
            {
                if (!file.EndsWith(".pcap"))
                {
                    continue;
                }

                Logger.Log("Processing PCAP file: " + file);

                _connectionDatas.Clear();

                PcapOfflineDevice device = SharpPcap.GetPcapOfflineDevice(file);
                device.PcapOpen();

                int outOfOrderCount = 0;
                Packet packet;
                do
                {
                    packet = device.PcapGetNextPacket();

                    TCPPacket tcpPacket = packet as TCPPacket;
                    if (tcpPacket == null)
                    {
                        continue;
                    }

                    if (!tcpPacket.SourceAddress.Equals(source) || !tcpPacket.DestinationAddress.Equals(destination))
                    {
                        continue;
                    }

                    ConnectionData connectionData;
                    if (!_connectionDatas.TryGetValue(getPacketId(tcpPacket), out connectionData))
                    {
                        connectionData = new ConnectionData();
                        _connectionDatas.Add(getPacketId(tcpPacket), connectionData);
                    }

                    //Logger.WriteConsole("Got Packet: " + packet);)
                    if (tcpPacket.Data.Length > 0)
                    {
                        if (tcpPacket.SequenceNumber != connectionData.Sequence && connectionData.Sequence != -1)
                        {
                            outOfOrderCount++;
                            connectionData.PacketCache.Add(tcpPacket);
                        }
                        else if (connectionData.Sequence == -1 || connectionData.Sequence == tcpPacket.SequenceNumber)
                        {
                            handleBytes(tcpPacket.Data);
                            connectionData.Sequence = tcpPacket.SequenceNumber + tcpPacket.PayloadDataLength;

                            List<TCPPacket> remove = new List<TCPPacket>();
                            foreach (TCPPacket outOfOrderPacket in connectionData.PacketCache)
                            {
                                if (connectionData.Sequence == outOfOrderPacket.SequenceNumber)
                                {
                                    remove.Add(outOfOrderPacket);
                                    handleBytes(outOfOrderPacket.Data);
                                    connectionData.Sequence = outOfOrderPacket.SequenceNumber + outOfOrderPacket.PayloadDataLength;
                                }
                            }

                            foreach (TCPPacket tcpPacket1 in remove)
                            {
                                connectionData.PacketCache.Remove(tcpPacket1);
                            }
                        }

                    }
                } while (packet != null && _working);

                Logger.WriteConsole("Out of Order Count: " + outOfOrderCount);

                foreach (KeyValuePair<string, ConnectionData> connectionData in _connectionDatas)
                {
                    Logger.Log("(" + connectionData.Key + ") Remaining packets: " + connectionData.Value.PacketCache.Count);
                    foreach (TCPPacket tcpPacket in connectionData.Value.PacketCache)
                    {
                        Logger.WriteConsole("\tSN: " + tcpPacket.SequenceNumber);
                    }
                }

                Logger.WriteConsole(string.Empty);
            }
        }