示例#1
0
        /// <summary>
        /// Puts down a record containing information about the specified broadcast recipient.
        /// </summary>
        /// <param name="writeFullInformation">True if it is necessary to write all settings of the ReceiverInfo.</param>
        /// <param name="receiverInfo">The ReceiverInfo.</param>
        public void WriteReceiverInfo(bool writeFullInformation, ReceiverInfo receiverInfo)
        {
            this.BinaryWriter.Write(receiverInfo != null);
            if (receiverInfo == null)
            {
                return;
            }

            this.BinaryWriter.Write((int)receiverInfo.DbgRecipientId);
            this.BinaryWriter.Write((bool)writeFullInformation);

            if (!writeFullInformation)
            {
                return;
            }

            this.WriteString(receiverInfo.MbrUri);
            this.BinaryWriter.Write((bool)receiverInfo.Local);

            if (receiverInfo.GeneralBroadcastSender != null)
            {
                this.WriteString(receiverInfo.GeneralBroadcastSender.Court);
            }
            else
            {
                this.BinaryWriter.Write(string.Empty);
            }
        }
示例#2
0
        private static ReceiverInfo TranslateReceiverInfo(ReceiverEntity entity)
        {
            ReceiverInfo info = new ReceiverInfo();

            if (entity != null)
            {
                info.CustomerID       = entity.CustomerID;
                info.ReceiverType     = entity.ReceiverType;
                info.DefaultCarrierID = entity.DefaultCarrierID;
                info.DefaultStorageID = entity.DefaultStorageID;
                info.ProvinceID       = entity.ProvinceID;
                info.CityID           = entity.CityID;
                info.Address          = entity.Address;
                info.Remark           = entity.Remark;

                info.OperatorID   = entity.OperatorID;
                info.ReceiverName = entity.ReceiverName;
                info.ReceiverNo   = entity.ReceiverNo;
                info.Status       = entity.Status;
                info.CreateDate   = entity.CreateDate;
                info.ChangeDate   = entity.ChangeDate;
                info.ReceiverID   = entity.ReceiverID;
            }
            return(info);
        }
示例#3
0
        /// <summary>
        /// Filters out the sender.
        /// </summary>
        /// <param name="cachedReceiverList">List of all potential recipients.</param>
        /// <param name="iMessage">The message being sent.</param>
        /// <returns>List of all recipients being called.</returns>
        public object[] GetReceivers(object[] cachedReceiverList, System.Runtime.Remoting.Messaging.IMessage iMessage)
        {
            object[] resultList         = new object[cachedReceiverList.Length];
            int      resultListPosition = 0;

            // by all receivers
            for (int i = 0; i < cachedReceiverList.Length; i++)
            {
                // get ReceiverInfo instance
                ReceiverInfo receiverInfo = cachedReceiverList[i] as ReceiverInfo;
                if (receiverInfo == null)
                {
                    continue;
                }

                // fetch the session
                ISessionSupport session = (ISessionSupport)receiverInfo.Tag;

                // and check on the call condition
                if ((string)session["UserId"] != this._userId)
                {
                    resultList[resultListPosition++] = receiverInfo;
                }
            }

            return(resultList);
        }
        private void AddReceiver(Type type)
        {
            var info = new ReceiverInfo {
                Name = ReceiverUtils.GetTypeDescription(type), Type = type
            };

            ReceiverTypes.Add(type.FullName ?? throw new InvalidOperationException(), info);
        }
示例#5
0
        private void AddReceiver(Type type)
        {
            var info = new ReceiverInfo {
                Name = ReceiverUtils.GetTypeDescription(type), Type = type
            };

            _receiverTypes.Add(type.FullName, info);
        }
示例#6
0
        public static ReceiverEntity GetReceiverById(long gid)
        {
            ReceiverEntity     result = new ReceiverEntity();
            ReceiverRepository mr     = new ReceiverRepository();
            ReceiverInfo       info   = mr.GetReceiverByKey(gid);

            result = TranslateReceiverEntity(info);
            return(result);
        }
示例#7
0
        public ReceiverInfo GetReceiverByKey(long gid)
        {
            ReceiverInfo result  = new ReceiverInfo();
            DataCommand  command = new DataCommand(ConnectionString, GetDbCommand(ReceiverStatement.GetReceiverByKey, "Text"));

            command.AddInputParameter("@ReceiverID", DbType.String, gid);
            result = command.ExecuteEntity <ReceiverInfo>();
            return(result);
        }
示例#8
0
        public static ReceiverEntity GetReceiverEntityById(long cid)
        {
            ReceiverEntity     result = new ReceiverEntity();
            ReceiverRepository mr     = new ReceiverRepository();
            ReceiverInfo       info   = mr.GetReceiverByKey(cid);

            if (info != null)
            {
                result = TranslateReceiverEntity(info);
                //获取联系人信息
                result.listContact = ContactService.GetContactByRule(UnionType.Receiver.ToString(), info.ReceiverID);
            }
            return(result);
        }
示例#9
0
        private void frm_ReceiverChangedEvent(object sender, ReceiverChangedEventArgs e)
        {
            EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;

            if (e.DisplayType == DisplayType.Add)
            {
                temp.ReceiveInfoList.Add(new ReceiverInfo(e.Name, e.EmailAddr));
            }
            else
            {
                ReceiverInfo info = temp.ReceiveInfoList[_curSelectReceiverIndex];
                info.Name      = e.Name;
                info.EmailAddr = e.EmailAddr;
            }
            eMailNotifyConfigBS.ResetBindings(false);
        }
示例#10
0
        public void Test_ReceiverInfo_ValidateActiveReceiver()
        {
            // Arrange
            var activeReceiver = new ReceiverInfo()
            {
                EntityName = "test",
                EntityType = EntityType.Queue,
                CreateEntityIfNotExists  = true,
                LockRenewalTimeInSeconds = 1,
                MaxLockDuration          = new TimeSpan(0, 0, 1)
            };

            // Act/Assert
            activeReceiver.ReceiverFullPath.Should().Be($"{activeReceiver.EntityName}");
            activeReceiver.LockRenewalTimeInSeconds.Should().Be(1);
        }
示例#11
0
        public void Test_ReceiverInfo_ReceiverFullPath()
        {
            // Arrange/Act
            var receiver = new ReceiverInfo {
                EntityType = EntityType.Topic
            };

            // Assert
            receiver.ReceiverFullPath.Should().BeNull();
            receiver.EntityName = "test";
            receiver.ReceiverFullPath.Should().BeNull();
            receiver.EntitySubscriptionName = "test";
            receiver.ReceiverFullPath.Should().Be("test/subscriptions/test");
            receiver.ReadFromErrorQueue = true;
            receiver.ReceiverFullPath.Should().Be("test/subscriptions/test/$deadletterqueue");
        }
        /// <summary>
        /// Returns a <see cref="string" /> that represents this instance.
        /// </summary>
        /// <returns>A <see cref="string" /> that represents this instance.</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine("INSTANCE INFO");
            sb.Append(" InstanceName: ");
            sb.AppendLine(InstanceName);
            sb.Append(" IsPremiumTierInstance: ");
            sb.AppendLine(IsPremiumTier.ToString());
            sb.Append(" ConnectionString: ");
            sb.AppendLine(ConnectionString.IsNullOrEmpty() ? "[NOT SET]" : "[SET]");
            sb.Append(Environment.NewLine);
            sb.AppendLine(ReceiverInfo != null ? ReceiverInfo.ToString() : "[RECEIVER NOT SET]");
            sb.AppendLine(SenderInfo != null ? SenderInfo.ToString() : "[SENDER NOT SET]");

            return(sb.ToString());
        }
示例#13
0
        public void Test_ReceiverInfo_ValidateErrorReceiver()
        {
            // Arrange/Act
            var errorReceiver = new ReceiverInfo()
            {
                EntityName = "test",
                EntityType = EntityType.Queue,
                CreateEntityIfNotExists  = true,
                ReadFromErrorQueue       = true,
                LockRenewalTimeInSeconds = 1,
                MaxLockDuration          = new TimeSpan(0, 0, 3)
            };

            // Assert
            errorReceiver.ReceiverFullPath.Should().Be($"{errorReceiver.EntityName}{ReceiverSetup.DeadLetterQueue}");
            errorReceiver.LockRenewalTimeInSeconds.Should().Be(3);
            AssertExtensions.DoesNotThrow(() => errorReceiver.Validate());
        }
示例#14
0
        private static ReceiverEntity TranslateReceiverEntity(ReceiverInfo info, bool isRead = true)
        {
            ReceiverEntity entity = new ReceiverEntity();

            if (info != null)
            {
                entity.CustomerID       = info.CustomerID;
                entity.ReceiverType     = info.ReceiverType;
                entity.DefaultCarrierID = info.DefaultCarrierID;
                entity.DefaultStorageID = info.DefaultStorageID;
                entity.ProvinceID       = info.ProvinceID;
                entity.CityID           = info.CityID;
                entity.Address          = info.Address;
                entity.Remark           = info.Remark;

                entity.OperatorID   = info.OperatorID;
                entity.ReceiverName = info.ReceiverName;
                entity.ReceiverNo   = info.ReceiverNo;
                entity.Status       = info.Status;
                entity.CreateDate   = info.CreateDate;
                entity.ChangeDate   = info.ChangeDate;
                entity.ReceiverID   = info.ReceiverID;

                if (isRead)
                {
                    City     city     = BaseDataService.GetAllCity().FirstOrDefault(t => t.CityID == info.CityID) ?? new City();
                    Province province = BaseDataService.GetAllProvince().FirstOrDefault(t => t.ProvinceID == info.ProvinceID) ?? new Province();
                    entity.province = province;
                    entity.city     = city;
                    entity.customer = new CustomerEntity();
                    entity.customer = CustomerService.GetCustomerById(info.CustomerID);

                    CarrierEntity carrier = CarrierService.GetCarrierById(info.DefaultCarrierID);
                    entity.Carrier = carrier;

                    StorageEntity storage = StorageService.GetStorageEntityById(info.DefaultStorageID);
                    entity.Storage = storage;
                }
                //获取联系人信息
                entity.listContact = ContactService.GetContactByRule(UnionType.Receiver.ToString(), info.ReceiverID);
            }

            return(entity);
        }
        /// <summary>
        /// Update the receiver entity using generic parameters
        /// </summary>
        /// <param name="entityName">The updated entity to listen to.</param>
        /// <param name="entitySubscriptionName">The updated subscription on the entity to listen to.</param>
        /// <param name="createIfNotExists">Creates the entity if it does not exist</param>
        /// <param name="entityFilter">A filter that will be applied to the entity if created through this method</param>
        /// <param name="supportStringBodyType">Support reading Service Bus message body as a string</param>
        /// <returns></returns>
        internal async Task UpdateReceiver(string entityName, string entitySubscriptionName, bool createIfNotExists, KeyValuePair <string, string>?entityFilter, bool supportStringBodyType = false)
        {
            // If no receiver exists (wasnt subscribed to), then create new.
            if (ReceiverInfo == null)
            {
                ReceiverInfo = new ReceiverInfo();
            }

            // Update the reciever info with the new config.
            ReceiverInfo.EntityType              = EntityType.Topic; //TODO: Future - need to know this, presumed Topic.
            ReceiverInfo.EntityName              = entityName;
            ReceiverInfo.EntitySubscriptionName  = entitySubscriptionName;
            ReceiverInfo.CreateEntityIfNotExists = createIfNotExists;
            ReceiverInfo.EntityFilter            = entityFilter;
            ReceiverInfo.SupportStringBodyType   = supportStringBodyType;

            // Ensure the entity manager is configured up.
            await SetAdditionalReceiverInfo();
        }
示例#16
0
        public int ModifyReceiver(ReceiverInfo Receiver)
        {
            DataCommand command = new DataCommand(ConnectionString, GetDbCommand(ReceiverStatement.ModifyReceiver, "Text"));

            command.AddInputParameter("@CustomerID", DbType.String, Receiver.CustomerID);
            command.AddInputParameter("@ReceiverName", DbType.String, Receiver.ReceiverName);
            command.AddInputParameter("@ReceiverNo", DbType.String, Receiver.ReceiverNo);
            command.AddInputParameter("@ProvinceID", DbType.Int32, Receiver.ProvinceID);
            command.AddInputParameter("@CityID", DbType.Int32, Receiver.CityID);
            command.AddInputParameter("@ReceiverType", DbType.String, Receiver.ReceiverType);
            command.AddInputParameter("@Address", DbType.String, Receiver.Address);
            command.AddInputParameter("@Remark", DbType.String, Receiver.Remark);
            command.AddInputParameter("@Status", DbType.Int32, Receiver.Status);
            command.AddInputParameter("@DefaultCarrierID", DbType.Int32, Receiver.DefaultCarrierID);
            command.AddInputParameter("@DefaultStorageID", DbType.Int32, Receiver.DefaultStorageID);
            command.AddInputParameter("@OperatorID", DbType.Int64, Receiver.OperatorID);
            command.AddInputParameter("@ChangeDate", DbType.DateTime, Receiver.ChangeDate);
            command.AddInputParameter("@ReceiverID", DbType.Int64, Receiver.ReceiverID);
            return(command.ExecuteNonQuery());
        }
示例#17
0
        /// <summary>
        /// Puts down a record describing a general Genuine Channels event.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="writeDispatcherSettings">A value indicating whether it is necessary to put down broadcast dispatcher's settings.</param>
        /// <param name="dispatcher">The broadcast dispatcher.</param>
        /// <param name="resultCollector">The broadcast result collector.</param>
        /// <param name="writeReceiverInfoSettings">A value indicating whether it is necessary to put down information about the specified broadcast recipient.</param>
        /// <param name="receiverInfo">The broadcast recipient.</param>
        /// <param name="string1">The first string that elaborates the current event.</param>
        /// <param name="string2">The second string that elaborates the current event.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteBroadcastEngineEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception,
                                              Message message, HostInformation remote, Stream content, int sourceThreadId, string sourceThreadName,
                                              SecuritySession securitySession, string securitySessionName,
                                              bool writeDispatcherSettings, Dispatcher dispatcher, ResultCollector resultCollector, bool writeReceiverInfoSettings,
                                              ReceiverInfo receiverInfo, string string1, string string2, string description, params object[] parameters)
        {
            if (dispatcher == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteBroadcastEngineEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The reference is null. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.TransportBroadcastEngineRecord, logCategory, type, author);
                this.WriteException(exception);

                this.WriteMessageSeqNo(message);
                this.WriteHostInformationId(remote);
                this.WriteBinaryContent(content);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionId(securitySession);
                this.WriteString(securitySessionName);

                this.WriteResultCollectorId(resultCollector);
                this.WriteDispatcherSettings(writeDispatcherSettings, dispatcher);
                this.WriteReceiverInfo(writeReceiverInfoSettings, receiverInfo);

                this.WriteString(string1);
                this.WriteString(string2);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
示例#18
0
        private void crystalButton_modifyRecv_Click(object sender, EventArgs e)
        {
            if (dataGridView_receiver.SelectedRows.Count == 0)
            {
                ShowCustomMessageBox(CommonUI.GetCustomMessage(HsLangTable, "SelectEditReceiver", "请选择要编辑的收件人!"),
                                     "", MessageBoxButtons.OK, MessageBoxIconType.Error);
                return;
            }
            using (Frm_ReceiverChanged frm = new Frm_ReceiverChanged())
            {
                frm.UpdateLanguage(HsLangTable);
                _curSelectReceiverIndex   = dataGridView_receiver.SelectedRows[0].Index;
                frm.ReceiverChangedEvent += new ReceiverChangedEventHandler(frm_ReceiverChangedEvent);

                EMailNotifyConfig temp = _uc_EMailNotify_VM.NotifyConfig;
                ReceiverInfo      info = temp.ReceiveInfoList[_curSelectReceiverIndex];

                frm.DisplayMode = DisplayType.Modify;
                frm.NameChanged = info.Name;
                frm.EmailAddr   = info.EmailAddr;
                frm.ShowDialog();
            }
        }
示例#19
0
        public long CreateNew(ReceiverInfo Receiver)
        {
            DataCommand command = new DataCommand(ConnectionString, GetDbCommand(ReceiverStatement.CreateNewReceiver, "Text"));

            command.AddInputParameter("@CustomerID", DbType.String, Receiver.CustomerID);
            command.AddInputParameter("@ReceiverName", DbType.String, Receiver.ReceiverName);
            command.AddInputParameter("@ReceiverNo", DbType.String, Receiver.ReceiverNo);
            command.AddInputParameter("@ProvinceID", DbType.Int32, Receiver.ProvinceID);
            command.AddInputParameter("@CityID", DbType.Int32, Receiver.CityID);
            command.AddInputParameter("@ReceiverType", DbType.String, Receiver.ReceiverType);
            command.AddInputParameter("@Address", DbType.String, Receiver.Address);
            command.AddInputParameter("@Remark", DbType.String, Receiver.Remark);
            command.AddInputParameter("@Status", DbType.Int32, Receiver.Status);
            command.AddInputParameter("@DefaultCarrierID", DbType.Int32, Receiver.DefaultCarrierID);
            command.AddInputParameter("@DefaultStorageID", DbType.Int32, Receiver.DefaultStorageID);
            command.AddInputParameter("@OperatorID", DbType.Int64, Receiver.OperatorID);
            command.AddInputParameter("@CreateDate", DbType.DateTime, Receiver.CreateDate);
            command.AddInputParameter("@ChangeDate", DbType.DateTime, Receiver.ChangeDate);

            var o = command.ExecuteScalar <object>();

            return(Convert.ToInt64(o));
        }
示例#20
0
        private static void SendSMS(object source, ElapsedEventArgs e)
        {
            string       bodyMessage = "Mensagem a ser enviada por SMS";
            ReceiverInfo Receiver    = new ReceiverInfo("cellNumber", bodyMessage, Properties.Settings.Default["API"].ToString());

            try
            {
                WebClient    client = new WebClient();
                Stream       stream = client.OpenRead(Receiver.UrlAPI);
                StreamReader reader = new StreamReader(stream);

                string          response        = reader.ReadToEnd();
                MessageResponse messageResponse = new JavaScriptSerializer().Deserialize <MessageResponse>(response);

                if (messageResponse.messages.Any(a => a.accepted))
                {
                    Console.WriteLine(string.Format("Data/Hora: {0} - Mensagem entregue com sucesso!", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#21
0
        /// <summary>
        /// Metodo per la generazione della ricevuta di avvenuta consegna
        /// </summary>
        /// <param name="interoperabilityMessage">Messaggio per cui generare la ricevuta</param>
        /// <param name="messageId">Id del messaggio ricevuto</param>
        /// <param name="receiver">Destinatario raggiunto</param>
        public static void GenerateProof(Interoperability.Domain.InteroperabilityMessage interoperabilityMessage, String messageId, ReceiverInfo receiver, InfoDocumentDelivered documentDelivered)
        {
            // Inizializzazione della ricevuta
            SuccessfullyDeliveredGenerator proof = new SuccessfullyDeliveredGenerator(
                interoperabilityMessage.Record.Subject, documentDelivered);

            // Generazione ricevuta
            ProofMessage message = proof.GenerateProof(
                interoperabilityMessage.Sender.Code,
                receiver.Code,
                messageId);

            AddProofToDocument(
                interoperabilityMessage.MainDocument.DocumentNumber,
                messageId,
                message.ProofContent,
                message.ProofDate,
                message.Receiver);
            // PEC 4 Modifica Maschera Caratteri
            InteroperabilitaSemplificataManager.AggiornaStatusMask("ANVAAAN", receiver.AOOCode, receiver.AdministrationCode, interoperabilityMessage.MainDocument.DocumentNumber);
        
        }
示例#22
0
 private void AddReceiver(Type type)
 {
   var info = new ReceiverInfo { Name = ReceiverUtils.GetTypeDescription(type), Type = type };
   _receiverTypes.Add(type.FullName, info);
 }
        /// <summary>
        /// A service bus specific way to update the receiver
        /// </summary>
        /// <param name="receiverInfo">Updated receiver information</param>
        /// <returns></returns>
        public async Task UpdateReceiver(ReceiverInfo receiverInfo)
        {
            ReceiverInfo = receiverInfo;

            await SetAdditionalReceiverInfo();
        }
示例#24
0
        public static bool ModifyReceiver(ReceiverEntity entity)
        {
            long result = 0;

            if (entity != null)
            {
                ReceiverRepository mr = new ReceiverRepository();

                ReceiverInfo ReceiverInfo = TranslateReceiverInfo(entity);

                ContactJsonEntity jsonlist = null;
                if (!string.IsNullOrEmpty(entity.ContactJson))
                {
                    try
                    {
                        jsonlist = (ContactJsonEntity)JsonHelper.FromJson(entity.ContactJson, typeof(ContactJsonEntity));
                    }
                    catch (Exception ex)
                    {
                        string str = ex.ToString();
                    }
                }

                if (entity.ReceiverID > 0)
                {
                    ReceiverInfo.ReceiverID = entity.ReceiverID;
                    ReceiverInfo.ChangeDate = DateTime.Now;
                    result = mr.ModifyReceiver(ReceiverInfo);
                }
                else
                {
                    ReceiverInfo.ChangeDate = DateTime.Now;
                    ReceiverInfo.CreateDate = DateTime.Now;
                    result = mr.CreateNew(ReceiverInfo);
                }

                #region 更新联系人信息
                if (jsonlist != null)
                {
                    List <ContactJson> list = jsonlist.listContact;
                    if (list != null && list.Count > 0)
                    {
                        foreach (ContactJson cc in list)
                        {
                            ContactRepository cr      = new ContactRepository();
                            ContactInfo       contact = new ContactInfo();
                            contact.ContactName = cc.ContactName;
                            contact.Mobile      = cc.Mobile;
                            contact.Telephone   = cc.Telephone;
                            contact.Email       = cc.Email;
                            contact.Remark      = cc.Remark;
                            contact.UnionType   = UnionType.Receiver.ToString();//客户
                            if (cc.ContactID > 0)
                            {
                                contact.ContactID  = cc.ContactID;
                                contact.UnionID    = entity.ReceiverID;
                                contact.ChangeDate = DateTime.Now;
                                cr.ModifyContact(contact);
                            }
                            else
                            {
                                contact.UnionID    = entity.ReceiverID > 0 ? entity.ReceiverID : result;
                                contact.CreateDate = DateTime.Now;
                                contact.ChangeDate = DateTime.Now;
                                cr.CreateNew(contact);
                            }
                        }
                    }
                }
                #endregion

                List <ReceiverInfo> miList = mr.GetAllReceiver();//刷新缓存
                Cache.Add("ReceiverALL", miList);

                Cache.Add("GetReceiverByCustomerID" + entity.CustomerID, miList);
            }
            return(result > 0);
        }
 /// <summary>
 /// 返回0表示成功
 /// </summary>
 /// <typeparam name="ParmaterTemplate"></typeparam>
 /// <param name="companySysNo"></param>
 /// <param name="receiverInfo"></param>
 /// <param name="parmater"></param>
 /// <returns></returns>
 public static int SendMsg <ParmaterTemplate>(int companySysNo, ReceiverInfo receiverInfo, ParmaterTemplate parmater, bool bl = true) where ParmaterTemplate : BaseMsgTemplate
 {
     return(SendMsg(companySysNo, new List <ReceiverInfo> {
         receiverInfo
     }, parmater, bl));
 }
示例#26
0
    /// <summary>
    /// Returns receivers that should be called.
    /// </summary>
    /// <param name="cachedReceiverList">All registered receivers (read-only cached array).</param>
    /// <param name="iMessage">The call.</param>
    /// <returns>Receivers that will be called.</returns>
    public object[] GetReceivers(object[] cachedReceiverList,
                                 IMessage iMessage)
    {
        // get string immediately from the call
        IMethodCallMessage iMethodCallMessage =
            (IMethodCallMessage)iMessage;
        IEnumerable <long> ids = iMethodCallMessage.Args[0] as IEnumerable <long>;

        if (ids == null)
        {
            return((new List <object>(cachedReceiverList)).ToArray());
        }

        // construct result list that will contain filtered receivers
        object[] resultList         = new object[cachedReceiverList.Length];
        int      resultListPosition = 0;

        AuthorizationService authSvc = (AuthorizationService)ServerEnvironment.AuthorizationService;

        // go though all the receivers
        for (int i = 0; i < cachedReceiverList.Length; i++)
        {
            // get the next receiver
            ReceiverInfo receiverInfo = cachedReceiverList[i] as ReceiverInfo;
            if (receiverInfo == null)
            {
                continue;
            }

            // obtain its session
            ISessionSupport session = (ISessionSupport)receiverInfo.Tag;
            User            u       = authSvc.GetUser(session["id"] as SessionId);
            if ((u == null) || (!u.UserRoleID.HasValue))
            {
                continue;
            }

            if (!((UserRoleId)(u.UserRoleID.Value) == UserRoleId.GlobalAdmin) && !_svc.Dao.IsPermittedAll(u, true))
            {
                List <string> pNames  = new List <string>();
                List <object> pValues = new List <object>();
                string        idList  = QueryUtils.GenIDList(ids, pNames, pValues);
                int           idCount = pValues.Count;
                IList         list    =
                    _svc.Dao.FindByNamedParam(new string[] { "entity.ID" }, null, string.Format("entity.ID IN ({0})", idList),
                                              null, pNames.ToArray(), pValues.ToArray(), true, u);
                if ((list == null) || (list.Count == 0))
                {
                    continue;
                }

                if (idCount != list.Count)
                {
                    List <long> newIds = new List <long>(list.Count);
                    foreach (long id in list)
                    {
                        newIds.Add(id);
                    }
                    iMethodCallMessage.Args[0] = newIds;
                }
            }

            resultList[resultListPosition++] = receiverInfo;
        }

        return(resultList);
    }