Esempio n. 1
0
        private static void Input_ButtonReleased(object sender, ButtonReleasedEventArgs e)
        {
            if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM)
            {
                if (e.Button == SButton.MouseLeft || e.Button == SButton.MouseMiddle || e.Button == SButton.MouseRight)
                {
                    try { IBM.OnMouseButtonReleased(e); }
                    catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Mouse button released: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); }
                }
                else if (e.Button == SButton.LeftShift || e.Button == SButton.RightShift || e.Button == SButton.LeftControl || e.Button == SButton.RightControl)
                {
                    try { IBM.OnModifierKeyReleased(e); }
                    catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Modifier key released: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); }
                }
                else if (e.Button.TryGetController(out Buttons GamepadButtons))
                {
                    try
                    {
                        //  Handle navigation buttons
                        foreach (NavigationDirection Direction in Enum.GetValues(typeof(NavigationDirection)).Cast <NavigationDirection>())
                        {
                            if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.NavigateSingleButtons[Direction]))
                            {
                                NavigationButtonsPressedTime.Remove(Direction);
                            }
                        }

                        IBM.OnGamepadButtonsReleased(GamepadButtons);
                    }
                    catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Gamepad button released: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); }
                }
            }
        }
Esempio n. 2
0
 private void Display_WindowResized(object sender, WindowResizedEventArgs e)
 {
     if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM)
     {
         IBM.OnWindowSizeChanged();
     }
 }
Esempio n. 3
0
        static void ObserverTester()
        {
            #region sample 1
            // Configure Observer pattern
            var s = new ConcreteSubject();

            s.Attach(new ConcreteObserver(s, "X"));
            s.Attach(new ConcreteObserver(s, "Y"));
            s.Attach(new ConcreteObserver(s, "Z"));

            // Change subject and notify observers
            s.SubjectState = "ABC";
            s.Notify();
            #endregion

            #region sample 2
            // Create IBM stock and attach investors
            var ibm = new IBM("IBM", 120.00);
            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
            #endregion
        }
Esempio n. 4
0
 private void GameLoop_UpdateTicked(object sender, UpdateTickedEventArgs e)
 {
     if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM)
     {
         IBM.Update(e);
     }
 }
Esempio n. 5
0
 private static void Input_MouseMoved(object sender, CursorMovedEventArgs e)
 {
     if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM)
     {
         try { IBM.OnMouseMoved(e); }
         catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Mouse moved: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); }
     }
 }
        public static void Main()
        {
            var ibm = new IBM("IBM", 120.00);
            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("New investor"));

            ibm.Price = 121.90;
            ibm.Price = 200.00;
        }
Esempio n. 7
0
    public static void Run()
    {
        var ibm      = new IBM("Microsoft", 100);
        var investor = new Investor("Igor");

        ibm.Attach(investor);
        ibm.Price = 300;
        ibm.Price = 200;
    }
        /// <summary>
        ///     Returns the list of following resources for the active user.
        ///     <para>API Reference: http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_the_My_Activities_feed_ic50&content=apicontent</para>
        /// </summary>
        ///// <param name="requestParameters"></param>
        /// <returns></returns>
        public FilesResult GetCommunityFiles(IBM.Connections.Net.Api.Models.Request.CommunityFiles requestParameters)
        {
            if(string.IsNullOrEmpty(requestParameters.CommunityId))
              return null;

               string url = string.Format("/files/basic/api/communitycollection/{0}/feed",requestParameters.CommunityId);

               return _apiService.Get<FilesResult>(url, requestParameters.ToDictionary());
        }
 /// <summary>
 ///     Returns the list of following resources for the active user.
 ///     <para>API Reference: http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_the_My_Activities_feed_ic50&content=apicontent</para>
 /// </summary>
 ///// <param name="limit"></param>
 /// <returns></returns>
 public Activities GetMyActivities(IBM.Connections.Net.Api.Models.Request.Activities request)
 {
     string url = string.Format("/activities/service/atom2/activities");
     //var requestData = new Dictionary<string, string>()
     //{
     //    {"limit", limit.ToString()}
     //};
        return _apiService.Get<Activities>(url, request.ToDictionary());
 }
Esempio n. 10
0
 public void Send(IBM.XMS.IMessage message)
 {
     if (!connected) Connect();
     producer.Send(message);
     if (transactional && System.Transactions.Transaction.Current == null)
     {
         session.Commit();
     }
 }
Esempio n. 11
0
        public static void Test()
        {
            IBM ibm = new IBM();

            ibm.Show();

            Dell dell = new Dell();

            dell.Show();
        }
Esempio n. 12
0
        public static void Main()
        {
            var ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("New investor"));

            ibm.Price = 121.90;
            ibm.Price = 200.00;
        }
Esempio n. 13
0
        static void Main()
        {
            IBM ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
        public static MvcHtmlString ProfileLinkFromActivity(this HtmlHelper helper, IBM.Connections.Net.Api.Models.ActivityStream.LinkInformation link, string username)
        {
            if (link == null)
            return MvcHtmlString.Create("");

             if (link != null && link.Href.IndexOf("/profiles/html/profileView.do?userid")>0)
             {
            return MvcHtmlString.Create(string.Format("<a href='{0}' target='_blank'>{1}</a>", link.Href,username));
             }else
            return MvcHtmlString.Create(string.Format("<a href='{0}' target='_blank'><img height='20px' src='/images/connectionscontent.png'></a>",link.Href));
        }
Esempio n. 15
0
        public static void StreamToMQMessage(Stream stream, IBM.WMQ.MQMessage msg)
        {
            stream.Seek(0, SeekOrigin.Begin);
            byte[] buffer = new byte[100 * 1024];

            int read = stream.Read(buffer, 0, buffer.Length);
            while (read > 0)
            {
                msg.Write(buffer, 0, read);
                read = stream.Read(buffer, 0, buffer.Length);
            }
        }
Esempio n. 16
0
        public JsonResult CalculateIBM(IBM i)
        {
            double BMI;

            i.BMIValue = (i.Weight / (i.Height * i.Height)) * 703;
            BMI        = i.BMIValue;


            var json = JsonConvert.SerializeObject(BMI);

            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public ObserverPattern()
        {
            IBM ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Observer("Daddy yanky"));
            ibm.Attach(new Observer("Sean Paul"));
            ibm.Attach(new Observer("Nikhilesh shinde"));

            ibm.Price = 120.11;
            ibm.Price = 120.01;
            ibm.Price = 120.61;
        }
Esempio n. 18
0
        public static void Execucao()
        {
            var ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("João"));
            ibm.Attach(new Investor("Maria"));

            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 19
0
        public JsonResult CalculateFatWomen(IBM i)
        {
            double FVW;


            i.FatValueWomen = 19.2 - (0.239 * i.Height) + (0.8 * i.AbdominalCircumference) - (0.5 * i.NeckCircumference);
            FVW             = i.FatValueWomen;

            var json = JsonConvert.SerializeObject(FVW);

            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            IBM ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 21
0
        static void RunObserverRealWorld()
        {
            IBM ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 22
0
        internal static void Main()
        {
            // Create IBM stock and attach investors
            var ibm = new IBM("IBM", 120.00);
            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 23
0
        public static void Test()
        {
            Investor s   = new Investor("张三");
            Investor b   = new Investor("李四");
            IBM      ibm = new IBM("IBM", 120.00);

            ibm.Attach(s);
            ibm.Attach(b);
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            Stock ibm           = new IBM("IBM", 120.2);
            var   firstInvestor = new Investor("Investor #1");

            ibm.Attach(firstInvestor);
            ibm.Attach(new Investor("Investor #2"));

            ibm.Price = 120.4;
            ibm.Detach(firstInvestor);
            ibm.Price = 125.58;
            ibm.Attach(new Investor("Investor #3"));
            ibm.Price = 120.99;
        }
Esempio n. 25
0
        public void TestObserverPrice()
        {
            IBM ibm = new IBM("IBM", 120.24);

            var i1 = new Investor("I1");
            var i2 = new Investor("I2");

            ibm.Attach(i1);
            ibm.Attach(i2);

            ibm.Price = 113.24;
            Assert.AreEqual(i1.Stock.Price, 113.24);
            Assert.AreEqual(i2.Stock.Price, 113.24);
        }
        public static void Main()
        {
            Stock ibm           = new IBM(nameof(IBM), 120.2);
            var   firstInvestor = new Investor(Constants.DisplayInvestor + 1);

            ibm.Attach(firstInvestor);
            ibm.Attach(new Investor(Constants.DisplayInvestor + 2));

            ibm.Price = 120.4;
            ibm.Detach(firstInvestor);
            ibm.Price = 125.58;
            ibm.Attach(new Investor(Constants.DisplayInvestor + 3));
            ibm.Price = 120.99;
        }
Esempio n. 27
0
        public static void ObserverRealWorld()
        {
            // Create IBM stock and attach investors
            IBM ibm = new IBM("IBM", 120.00);

            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 28
0
            public void Main()
            {
                // Create IBM stock and attach investors
                IBM ibm = new IBM(120.00);

                ibm.Attach(new Investor("Sorros"));
                ibm.Attach(new Investor("Berkshire"));

                // Fluctuating prices will notify investors
                ibm.Price = 120.10;
                ibm.Price = 121.00;
                ibm.Price = 120.50;
                ibm.Price = 120.75;
            }
Esempio n. 29
0
        static void Main(string[] args)
        {
            {
                IBM ibm = new IBM("IBM", 120.00);
                ibm.Attach(new Investor("Sorros"));
                ibm.Attach(new Investor("Berkshire"));

                ibm.Price = 120.10;
                ibm.Price = 121.00;
                ibm.Price = 120.50;
                ibm.Price = 120.75;

                Console.ReadKey();
            }
        }
Esempio n. 30
0
 public void Initialize()
 {
     _ibm               = new IBM(120.00);
     _investors         = new List <Mock <IInvestor> >();
     _notifiedInvestors = 0;
     for (var i = 0; i < 3; i++)
     {
         var investor = new Mock <IInvestor>();
         investor.Setup(c => c.Update(_ibm)).Callback(() =>
         {
             _notifiedInvestors++;
         });
         _investors.Add(investor);
     }
 }
 public void Send(IBM.XMS.IMessage message)
 {
     try
     {
         producer.Send(message);
         log.Debug("Commiting per call transaction.");
         session.Commit();
     }
     catch (Exception)
     {
         log.Debug("Rolling back per call transaction.");
         session.Rollback();
         throw;
     }
 }
Esempio n. 32
0
        public static void MQMessageToStream(IBM.WMQ.MQMessage msg, Stream stream)
        {
            byte[] buffer = new byte[100 * 1024];
            int bytesToRead = msg.DataLength > buffer.Length ? buffer.Length : msg.DataLength;
            buffer = msg.ReadBytes(bytesToRead);
            stream.Write(buffer, 0, bytesToRead);

            while (msg.DataLength > 0)
            {
                bytesToRead = msg.DataLength > buffer.Length ? buffer.Length : msg.DataLength;
                buffer = msg.ReadBytes(bytesToRead);
                stream.Write(buffer, 0, bytesToRead);
            }
            stream.Seek(0, SeekOrigin.Begin);
        }
Esempio n. 33
0
        private static void ObserverDemo()
        {
            var ibm       = new IBM("IBM", 120.00);
            var investor1 = new Investor("Sorros");
            var investor2 = new Investor("Berkshire");

            ibm.StartWatching(investor1.Update);
            ibm.StartWatching(investor2.Update);

            ibm.UpdatePrice(120.10);
            ibm.UpdatePrice(121.00);
            ibm.StopWatching(investor1.Update);
            ibm.UpdatePrice(120.50);
            ibm.StopWatching(investor2.Update);
            ibm.UpdatePrice(120.75);
        }
Esempio n. 34
0
    // Entry point into console application.
    static void Main()
    {
        // Create IBM stock and attach investors
        IBM ibm = new IBM("IBM", 120.00);
        ibm.Attach(new Investor("Sorros"));
        ibm.Attach(new Investor("Berkshire"));

        // Fluctuating prices will notify investors
        ibm.Price = 120.10;
        ibm.Price = 121.00;
        ibm.Price = 120.50;
        ibm.Price = 120.75;

        // Wait for user
        Console.ReadKey();
    }
Esempio n. 35
0
        //简单工厂最核心的地方
        public static NoteBook GetNoteBook(string note)
        {
            NoteBook nb = null;

            switch (note)
            {
            case "Acer": nb = new Acer(); break;

            case "IBM": nb = new IBM(); break;

            case "DELL": nb = new DELL(); break;

            case "Lenovo": nb = new Lenovo(); break;
            }
            return(nb);
        }
Esempio n. 36
0
        static void Main(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            var ibm = new IBM("International Bussness Machine", 12);

            ibm.AttachInvestor(new Investor("Broker1"));
            ibm.AttachInvestor(new Investor("Broker2"));

            ibm.Price = 20;
            ibm.Price = 100;
            ibm.Price = 100;

            Console.ReadKey();
        }
Esempio n. 37
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            static void Main()
            {
                // Create IBM stock and attach investors
                IBM ibm = new IBM("IBM", 120.00);

                ibm.Attach(new Investor("Sorros"));
                ibm.Attach(new Investor("Berkshire"));

                // Fluctuating prices will notify investors
                ibm.Price = 120.10;
                ibm.Price = 121.00;
                ibm.Price = 120.50;
                ibm.Price = 120.75;

                // Wait for user
                Console.ReadKey();
            }
Esempio n. 38
0
        /// <summary>
        /// 简单工厂的核心 根据用户的输入创建对象赋值给父类
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public static NoteBook GetNoteBook(string brand)
        {
            NoteBook nb = null;

            switch (brand)
            {
            case "Lenovo": nb = new Lenovo();   //创建子类的对象,赋值给父类
                break;

            case "IBM": nb = new IBM();
                break;

            case "Acer": nb = new Acer();
                break;

            case "Dell": nb = new Dell();
                break;
            }
            return(nb);
        }
        public void Run()
        {
            // Skapa ibm-aktien
            IBM ibm = new IBM("IBM", 120.00);

            // En extra investor
            var myInvestor = new Investor("happybits");

            // Vi lägger till investerare
            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));
            ibm.Attach(myInvestor);

            // När priset ändras så blir investorerna meddelade
            ibm.Price = 120.10;
            ibm.Price = 121.00;

            // Nu tar vi bort en investor och fortsätter ändra priset
            ibm.Detach(myInvestor);
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }
Esempio n. 40
0
        private static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Gang of Four Design Pattern - Observer");
            Console.ForegroundColor = ConsoleColor.White;

            // Create IBM stock and attach investors
            var ibm = new IBM("International Business Machines", "IBM", 120.00m);

            ibm.Attach(new StockInvestor {
                Name = "Tim"
            });
            ibm.Attach(new StockInvestor {
                Name = "John"
            });

            // Fluctuating prices will notify investors
            ibm.Price = 120.10m;
            ibm.Price = 121.00m;
            ibm.Price = 120.50m;
            ibm.Price = 120.75m;
        }
Esempio n. 41
0
 /// <summary>
 ///   Moves the given message to the configured error queue.
 /// </summary>
 /// <param name = "m"></param>
 protected void MoveToErrorQueue(IBM.XMS.IMessage m)
 {
     using(var producer = producerProvider.GetProducer(errorDestination))
     {
         if(m is IBytesMessage)
         {
             var toSend = producer.CreateBytesMessage();
             XmsUtilities.PopulateErrorQueueMessage(toSend, (IBytesMessage)m, inputDestination);
             producer.Send(m);
         }
         else
         {
             log.Error("Received message of type {0} which is not supported. This message will be ignored.".FormatWith(m.GetType()));
         }
     }
 }
        public ActivityStream SetMyStatus(IBM.Connections.Net.Api.Models.Request.UpdateStatus request)
        {
            string url = string.Format("/connections/opensocial/basic/rest/ublog/{0}/@all?format=atom", _apiService.config.GetUserID());

               return _apiService.Post<ActivityStream>(url, request.ToDictionary());
        }
Esempio n. 43
0
  public static void Main( string[] args )
  {
    // Create investors
    Investor s = new Investor( "Sorros" );
    Investor b = new Investor( "Berkshire" );

    // Create IBM stock and attach investors
    IBM ibm = new IBM( "IBM", 120.00 );
    ibm.Attach( s );
    ibm.Attach( b );

    // Change price, which notifies investors
    ibm.Price = 120.10;
    ibm.Price = 121.00;
    ibm.Price = 120.50;
    ibm.Price = 120.75;
  }
Esempio n. 44
0
 public void Send(IBM.XMS.IMessage message)
 {
     producer.Send(message);
 }
Esempio n. 45
0
        public static TransportMessage Convert(IBM.XMS.IMessage m)
        {
            var result = new TransportMessage();
            result.Id = GetRealMessageId(m);
            result.CorrelationId = m.JMSCorrelationID;
            result.Recoverable = m.JMSDeliveryMode == DeliveryMode.Persistent;
            result.IdForCorrelation = m.GetStringProperty(HEADER_IDFORCORRELATION);
            result.ReturnAddress = m.GetStringProperty(HEADER_RETURNADDRESS);
            result.WindowsIdentityName = m.GetStringProperty(HEADER_WINDOWSIDENTITYNAME);
            result.MessageIntent = (MessageIntentEnum) m.GetIntProperty(HEADER_MESSAGEINTENT);
            result.TimeSent = baseDate.AddMilliseconds(m.JMSTimestamp);
            result.Headers = new List<HeaderInfo>();
            //TODO:
            //result.TimeToBeReceived = DateTime.UtcNow - baseDate.AddMilliseconds(m.JMSExpiration);
            if (m.GetStringProperty("NSBKeys") != null)
            {
                var keys = UnwrapKeys(m.GetStringProperty("NSBKeys"));

                result.Headers = (from k in keys
                                  select new HeaderInfo
                                             {
                                                 Key = k.FromXmsFriendly(),
                                                 Value = m.GetStringProperty(k)
                                             }).ToList();
            }

            //TODO:
            //TimeToBeReceived = baseDate.AddMilliseconds(m.JMSTimestamp),
            //ReplyToAddress = GetIndependentAddressForQueue(m.ResponseQueue),
            return result;
        }
 public void Send(IBM.XMS.IMessage message)
 {
     sendAction(message);
 }
Esempio n. 47
0
        // TODO: test this
        public static void PopulateErrorQueueMessage(IBytesMessage toSend, IBM.XMS.IBytesMessage failed, XmsDestination xmsDestination)
        {
            var body = new byte[failed.BodyLength];
            if (body.Length > 0)
            {
                failed.ReadBytes(body, body.Length);
                toSend.WriteBytes(body);
            }
            toSend.JMSCorrelationID = failed.JMSCorrelationID;
            toSend.JMSDeliveryMode = failed.JMSDeliveryMode;
            toSend.CopyStringProperty(HEADER_RETURNADDRESS, failed);
            toSend.CopyStringProperty(HEADER_IDFORCORRELATION, failed);
            toSend.CopyStringProperty(HEADER_WINDOWSIDENTITYNAME, failed);
            toSend.CopyStringProperty(HEADER_MESSAGEINTENT, failed);

            var keys = failed.GetStringProperty(HEADER_NBSKEYS);
            var unwrapedKeys = UnwrapKeys(keys);
            foreach (var unwrapedKey in unwrapedKeys)
            {
                toSend.CopyStringProperty(unwrapedKey, failed);
            }

            toSend.CopyStringProperty(HEADER_NBSKEYS, failed);
            
            // error queue specific
            toSend.SetStringProperty(HEADER_FAILEDQUEUE, xmsDestination.ToString());
            var id = failed.GetStringProperty(HEADER_ORIGINALID);
            toSend.SetStringProperty(HEADER_ORIGINALID, id);
        }
Esempio n. 48
0
        public static TransportMessage Convert(IBM.XMS.IMessage m)
        {
            var result = new TransportMessage();
            result.Id = GetRealMessageId(m);
            result.CorrelationId = m.JMSCorrelationID;
            result.Recoverable = m.JMSDeliveryMode == DeliveryMode.Persistent;
            result.IdForCorrelation = m.GetStringProperty(HEADER_IDFORCORRELATION);
            result.ReplyToAddress = m.GetStringProperty(HEADER_RETURNADDRESS).ToXmsAddress().ToNsbAddress();
            //result.WindowsIdentityName = m.GetStringProperty(HEADER_WINDOWSIDENTITYNAME);
            result.MessageIntent = (MessageIntentEnum)m.GetIntProperty(HEADER_MESSAGEINTENT);
            //result.TimeSent = baseDate.AddMilliseconds(m.JMSTimestamp);
            result.Headers = new Dictionary<string, string>();
            //TODO:
            //result.TimeToBeReceived = DateTime.UtcNow - baseDate.AddMilliseconds(m.JMSExpiration);
            if (m.GetStringProperty("NSBKeys") != null)
            {
                var keys = UnwrapKeys(m.GetStringProperty("NSBKeys"));

                result.Headers = (from k in keys
                                  select new {Key = k.FromXmsFriendly(), Value = m.GetStringProperty(k)})
                                  .ToDictionary(x=>x.Key,x=>x.Value);
            }

            //TODO:
            //TimeToBeReceived = baseDate.AddMilliseconds(m.JMSTimestamp),
            //ReplyToAddress = GetIndependentAddressForQueue(m.ResponseQueue),
            var byteMessage = m as IBytesMessage;
            if (byteMessage == null)
            {
                return null;
            }
            if (byteMessage.BodyLength > 0)
            {
                var body = new byte[byteMessage.BodyLength];
                byteMessage.ReadBytes(body);
                result.Body = body;
            }
            return result;

/*
            TransportMessage transportMessage = new TransportMessage()
            {
                Id = m.Id,
                CorrelationId = m.CorrelationId == "00000000-0000-0000-0000-000000000000\\0" ? (string)null : m.CorrelationId,
                Recoverable = m.Recoverable,
                TimeToBeReceived = m.TimeToBeReceived,
                TimeSent = m.SentTime,
                ReplyToAddress = MsmqUtilities.GetIndependentAddressForQueue(m.ResponseQueue),
                MessageIntent = Enum.IsDefined(typeof(MessageIntentEnum), (object)m.AppSpecific) ? (MessageIntentEnum)m.AppSpecific : MessageIntentEnum.Send
            };
            m.BodyStream.Position = 0L;
            transportMessage.Body = new byte[m.BodyStream.Length];
            m.BodyStream.Read(transportMessage.Body, 0, transportMessage.Body.Length);
            transportMessage.Headers = new Dictionary<string, string>();
            if (m.Extension.Length > 0)
            {
                MemoryStream memoryStream = new MemoryStream(m.Extension);
                foreach (HeaderInfo headerInfo in MsmqUtilities.headerSerializer.Deserialize((Stream)memoryStream) as List<HeaderInfo>)
                {
                    if (headerInfo.Key != null)
                        transportMessage.Headers.Add(headerInfo.Key, headerInfo.Value);
                }
            }
            transportMessage.Id = TransportHeaderKeys.GetOriginalId(transportMessage);
            if (transportMessage.Headers.ContainsKey("EnclosedMessageTypes"))
                MsmqUtilities.ExtractMsmqMessageLabelInformationForBackwardCompatibility(m, transportMessage);
            transportMessage.IdForCorrelation = TransportHeaderKeys.GetIdForCorrelation(transportMessage);
            return transportMessage;*/

        }
Esempio n. 49
0
        //private static DateTime baseDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

        public static string GetRealMessageId(IBM.XMS.IMessage message)
        {
            var id = message.GetStringProperty(HEADER_ORIGINALID);
            return string.IsNullOrEmpty(id) ? message.JMSMessageID : id;
        }
        public PostResult CreateFolder(IBM.Connections.Net.Api.Models.Request.CreateFolder requestParameters)
        {
            string url = string.Format("/files/basic/api/collections/feed");

             return _apiService.Post<PostResult>(url, requestParameters.ToDictionary());
        }
        /// <summary>
        ///     Returns the list of shared resources from or to the active user.
        ///     <para>API Reference:http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_a_feed_of_file_shares_ic50&content=apicontent
        /// </summary>
        ///// <param name="requestParameters"></param>
        /// <returns></returns>
        public FilesResult GetFileShared(IBM.Connections.Net.Api.Models.Request.FilesShared requestParameters)
        {
            string url = string.Format("/files/basic/api/documents/shared/feed");

             return _apiService.Get<FilesResult>(url, requestParameters.ToDictionary());
        }
        /// <summary>
        ///     Returns the list of following resources for the active user.
        ///     <para>API Reference: http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_the_My_Activities_feed_ic50&content=apicontent</para>
        /// </summary>
        ///// <param name="requestParameters"></param>
        /// <returns></returns>
        public FilesResult GetMyFiles(IBM.Connections.Net.Api.Models.Request.Files requestParameters)
        {
            string url = string.Format("/files/basic/api/myuserlibrary/feed");

             return _apiService.Get<FilesResult>(url, requestParameters.ToDictionary());
        }
Esempio n. 53
0
 private void ForwardMessage(IBM.XMS.IMessage m)
 {
     try
     {
         using(var producer = producerProvider.GetProducer(forwardDestination))
         {
             producer.Send(m);
         }
     }
     catch (Exception ex)
     {
         log.Error("Unexpected error while forwarding message to {0}.".FormatWith(forwardDestination),ex);
         throw;
     }
 }
        /// <summary>
        ///     Returns the list of available communities for the active user.
        ///     <para>API Reference: http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_the_My_Communities_feed_ic50&content=apicontent
        /// </summary>
        ///// <param name="limit"></param>
        /// <returns></returns>
        public CommunitiesResult GetMyCommunities(IBM.Connections.Net.Api.Models.Request.Communities request)
        {
            string url = string.Format("/communities/service/atom/communities/my");

               return _apiService.Get<CommunitiesResult>(url, request.ToDictionary());
        }
        public ProfilesResult GetCollegues(IBM.Connections.Net.Api.Models.Request.Profiles request)
        {
            string url = string.Format("/profiles/atom2/forms/viewallfriends.xml");

             return _apiService.Get<ProfilesResult>(url, request.ToDictionary());
        }
        public ProfilesResult GetPeopleFollowing(IBM.Connections.Net.Api.Models.Request.ProfilesFollow request)
        {
            string url = string.Format("/profiles/follow/atom/resources");

             return _apiService.Get<ProfilesResult>(url, request.ToDictionary());
        }
        public ProfilesResult GetPeopleStatus(IBM.Connections.Net.Api.Models.Request.Status request)
        {
            string url = string.Format("/profiles/atom/mv/theboard/entries/related.do");

             return _apiService.Get<ProfilesResult>(url, request.ToDictionary());
        }
        /// <summary>
        ///     Returns the list of following resources for the active user.
        ///     <para>API Reference: http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Getting_the_My_Activities_feed_ic50&content=apicontent</para>
        /// </summary>
        ///// <param name="limit"></param>
        /// <returns></returns>
        public FilesResult GetPinnedFiles(IBM.Connections.Net.Api.Models.Request.Files requestParameters)
        {
            string url = string.Format("/files/basic/api/myfavorites/documents/feed");

             return _apiService.Get<FilesResult>(url, requestParameters.ToDictionary());
        }