コード例 #1
0
        public void SendTriggeredMessageToXDB(Guid messageId, Guid contactId, bool usePreferredLanguage = false,
                                              IDictionary <string, object> customPersonTokens           = null)
        {
            RecipientId recipientId = RecipientRepository.GetDefaultInstance().ResolveRecipientId("xdb:" + contactId);

            Sitecore.Modules.EmailCampaign.Application.Application.Instance.EmailDispatch.SendTriggered(messageId, recipientId, usePreferredLanguage, customPersonTokens);
        }
コード例 #2
0
ファイル: Transaction.cs プロジェクト: twistys01/LiskSharp
        public byte[] GetBytes(bool skipSignature = false)
        {
            int assetSize = 0;

            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());
                    if (RecipientId != null)
                    {
                        var recId = new BigInteger(RecipientId.Replace("L", ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }
                    writer.Write(Amount);
                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }
                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
コード例 #3
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            LoadAuthentication(context);

            templateId  = TemplateId.Get(context);
            recipientId = RecipientId.Get(context);
            filePath    = FilePath.Get(context);

            CreateBulkEnvelopeDelegate = new Action(_AddBulkRecipientAction);
            return(CreateBulkEnvelopeDelegate.BeginInvoke(callback, state));
        }
コード例 #4
0
        public void GetCancellableTransferTasks_noUnrecordedTasks()
        {
            var lApplicationId         = System.Configuration.ConfigurationSettings.AppSettings["ApplicationId"];
            var lInputTransferTaskList = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskList();
            var lInputTasks3           = new PIS.Ground.Core.T2G.WebServices.FileTransfer.transferTaskStruct();

            lInputTasks3.taskId    = 34;
            lInputTasks3.taskState = PIS.Ground.Core.T2G.WebServices.FileTransfer.taskStateEnum.taskStarted;
            lInputTransferTaskList.Add(lInputTasks3);

            var lInputDistributionRequest1 = new FileDistributionRequestForTest();
            var lInputRecipient1           = new RecipientId();

            lInputRecipient1.SystemId      = "train1";
            lInputRecipient1.ApplicationId = lApplicationId;
            var lInputRecipient2 = new RecipientId();

            lInputRecipient2.SystemId      = "train2";
            lInputRecipient2.ApplicationId = lApplicationId;
            var lInputRecipient3 = new RecipientId();

            lInputRecipient3.SystemId      = "train3";
            lInputRecipient3.ApplicationId = lApplicationId;

            lInputDistributionRequest1.RecipientList.AddRange(
                new RecipientId[] { lInputRecipient1, lInputRecipient2, lInputRecipient3 });

            var lInputUnrecordedRecipients   = new List <Recipient>();
            var lInputUnrecordedTransferTask = new TransferTaskData();

            _train2groundClientMock.Setup(x => x.EnumTransferTask(
                                              It.IsAny <DateTime>(), It.IsAny <DateTime>(), out lInputTransferTaskList))
            .Returns(true);

            _train2groundClientMock.Setup(x => x.GetFileDistributionRequestByTaskId(
                                              It.Is <int>((lValue) => lValue == 34)))
            .Returns(lInputDistributionRequest1);

            List <DataPackageService.CancellableTransferTaskInfo> lOutputTransferTask;
            bool lSuccess = DataPackageServiceInstrumented.getCancellableTransferTasks(out lOutputTransferTask);

            _train2groundClientMock.Verify(x => x.GetTransferTask(
                                               It.IsAny <int>(), out lInputUnrecordedRecipients, out lInputUnrecordedTransferTask),
                                           Times.Never());

            Assert.AreEqual(1, lOutputTransferTask.Count, "Number of expected transfer task results");
            Assert.AreEqual(34, lOutputTransferTask[0].TaskID, "Recorded task id");
            Assert.AreEqual(3, lOutputTransferTask[0].Elements.Count, "Number of elements");
            Assert.AreEqual("train1", lOutputTransferTask[0].Elements[0], "First element");
            Assert.AreEqual("train2", lOutputTransferTask[0].Elements[1], "Second element");
            Assert.AreEqual("train3", lOutputTransferTask[0].Elements[2], "Third element");
            Assert.IsTrue(lSuccess);
        }
コード例 #5
0
        /// <summary>
        /// Callback called when a download folder is published on the train (signaled by the T2G client)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="status"></param>
        private static void OnFilesPublished(object sender, FilePublishedNotificationArgs status)
        {
            LogManager.WriteLog(TraceType.INFO, "OnFilesPublished called, folderId=" + status.FolderId + " systemId=" + status.SystemId, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling);

            try
            {
                string      lGetFolderInformationError;
                IFolderInfo lFolderInfo = _t2gManager.T2GFileDistributionManager.GetRemoteFolderInformation(status.FolderId, status.SystemId, ConfigurationSettings.AppSettings["ApplicationId"], out lGetFolderInformationError);
                if (lFolderInfo != null)
                {
                    List <RecipientId> lRecipientIdList = new List <RecipientId>();

                    RecipientId lRecipient = new RecipientId();
                    lRecipient.ApplicationId = ConfigurationSettings.AppSettings["ApplicationId"];
                    lRecipient.MissionId     = string.Empty;
                    lRecipient.SystemId      = "ground";
                    lRecipientIdList.Add(lRecipient);

                    DownloadFolderRequest objRequest = new DownloadFolderRequest(
                        new Guid(lFolderInfo.FolderName),                   // The folder name should have the GUID-formatted name, this is our request ID
                        lFolderInfo.ExpirationDate,                         // Set to the folder's expiration date
                        lFolderInfo.FolderName,
                        lRecipientIdList,
                        DateTime.Now,                         //Start date: now
                        "InfotainmentJournaling Service Transfer Task",
                        FileTransferMode.AnyBandwidth,
                        16,                         //normal priority
                        new EventHandler <FileDistributionStatusArgs>(OnFilesDistribution),
                        status.FolderId);

                    objRequest.SystemId    = status.SystemId;
                    objRequest.Compression = false;

                    String lErrorMessage = _t2gManager.T2GFileDistributionManager.DownloadFolder(objRequest);
                    if (!String.IsNullOrEmpty(lErrorMessage))
                    {
                        LogManager.WriteLog(TraceType.ERROR, "T2G DownloadFolder failure, error " + lErrorMessage, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling);
                    }
                }
                else
                {
                    LogManager.WriteLog(TraceType.ERROR, "Failure to retrieve folder info, error " + lGetFolderInformationError, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling);
                }
            }
            catch (System.Exception e)
            {
                LogManager.WriteLog(TraceType.ERROR, "Exception thrown", "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", e, EventIdEnum.InfotainmentJournaling);
            }
        }
コード例 #6
0
ファイル: Transaction.cs プロジェクト: zebbra2014/RiseSharp
        public byte[] GetBytes()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());

                    if (!string.IsNullOrWhiteSpace(RecipientId))
                    {
                        var recId = new BigInteger(RecipientId.Replace(Constants.AddressSuffix, ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }

                    writer.Write(Amount);

                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }

                    if (!string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }

                    if (!string.IsNullOrWhiteSpace(SignSignature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
コード例 #7
0
        }                                 //kwota przelewu


        public override string ToString() //przeciazenie metody do string
        {
            return("\n##OD: " + SenderId.ToString() + " DLA: " + RecipientId.ToString() + " KWOTA: " + Amount.ToString() + "##");
        }
コード例 #8
0
 public ActionResult Index(SubscribeModel subscribe)
 {
     if (ModelState.IsValid)
     {
         using (new SecurityDisabler())
         {
             try
             {
                 string            emailAddress      = subscribe.Email;
                 EmailHelper       emailhelper       = new EmailHelper();
                 ContactRepository contactRepository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository;
                 var            contact        = contactRepository.LoadContactReadOnly(emailAddress);
                 ContactManager contactManager = Sitecore.Configuration.Factory.CreateObject("tracking/contactManager", true) as ContactManager;
                 LockAttemptResult <Contact> lockResult;
                 if (contact == null)
                 {
                     lockResult = new LockAttemptResult <Contact>(LockAttemptStatus.NotFound, null, null);
                     contact    = contactRepository.CreateContact(Sitecore.Data.ID.NewID);
                     contact.Identifiers.AuthenticationLevel = Sitecore.Analytics.Model.AuthenticationLevel.None;
                     contact.Identifiers.Identifier          = emailAddress;
                     contact.Identifiers.IdentificationLevel = ContactIdentificationLevel.Known;
                     contact.System.Value      = 0;
                     contact.System.VisitCount = 0;
                     contact.ContactSaveMode   = ContactSaveMode.AlwaysSave;
                     contactManager.FlushContactToXdb(contact);
                 }
                 else
                 {
                     lockResult = contactManager.TryLoadContact(contact.ContactId);
                     contact    = lockResult.Object;
                 }
                 var personal = contact.GetFacet <Sitecore.Analytics.Model.Entities.IContactPersonalInfo>("Personal");
                 personal.FirstName = subscribe.FullName;
                 var emailAddresses = contact.GetFacet <Sitecore.Analytics.Model.Entities.IContactEmailAddresses>("Emails");
                 if (!emailAddresses.Entries.Contains("Email"))
                 {
                     emailAddresses.Entries.Create("Email");
                 }
                 var email = emailAddresses.Entries["Email"];
                 email.SmtpAddress        = emailAddress;
                 emailAddresses.Preferred = "Email";
                 var contactEmailAddresses = contact.GetFacet <IVisitorSubscribtionFacet>("Contact Details");
                 if (!contactEmailAddresses.SubscriptionDetails.Contains("Subscriber Details"))
                 {
                     contactEmailAddresses.SubscriptionDetails.Create("Subscriber");
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].FullName      = subscribe.FullName;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].ContactNumber = subscribe.ContactNumber;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].Email         = subscribe.Email;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].Comments      = subscribe.Comments;
                 }
                 ContactListManager listManager = Sitecore.Configuration.Factory.CreateObject("contactListManager", false) as ContactListManager;
                 contactManager.SaveAndReleaseContactToXdb(contact);
                 Tracker.Current.Session.Identify(subscribe.Email);
                 //Getting the Email Campaign ManagerRoot
                 Item        managerRoot = Sitecore.Data.Database.GetDatabase(SitecoreHelper.GetSitecoreDB().ToString()).GetItem(GlobalProperties.EmailCampaignMangerRoot);
                 RecipientId recipient   = RecipientRepository.GetDefaultInstance().ResolveRecipientId("xdb:" + contact.ContactId);
                 var         recipientId = new Sitecore.Modules.EmailCampaign.Xdb.XdbContactId(contact.ContactId);
                 Sitecore.Modules.EmailCampaign.ClientApi.UpdateSubscriptions(recipientId, new[] { GlobalGuids.ContactList }, new string[] { }, managerRoot.ID.ToString(), false);
                 emailhelper.SendEmail(subscribe);
                 subscribe.IsFormEnabled = false;
             }
             catch (Exception ex)
             {
                 subscribe.IsError       = true;
                 subscribe.IsFormEnabled = false;
                 Sitecore.Diagnostics.Log.Error(ex.Message, this);
             }
         }
         return(View("~/Views/Pages/Subscribe.cshtml", subscribe));
     }
     subscribe.IsError       = false;
     subscribe.IsFormEnabled = true;
     return(View("~/Views/Pages/Subscribe.cshtml", subscribe));
 }