예제 #1
0
        public ActionResult GetPreservationVerifyTask([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult              result          = new DataSourceResult();
            CustomerCompanyViewModel      customerCompany = Session["idCompany"] as CustomerCompanyViewModel;
            BindingList <DocumentArchive> archives        = new BindingList <DocumentArchive>();

            try
            {
                if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false")
                {
                    archives = CustomerService.GetCustomerArchivesByUsername(User.Identity.Name);
                }
                else
                {
                    archives = new BindingList <DocumentArchive>(ArchiveService.GetLegalArchives("", customerCompany.CompanyId).Select(x => x.Archive).ToList());
                }
                var tasks = new PreservationService().GetPreservationVerify(archives.Select(x => x.IdArchive).ToArray(), true);
                result.Total = tasks.Count;
                result.Data  = tasks;
            }
            catch (Exception ex)
            {
                result.Errors = ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
    public BindingList <Document> GetAllDocumentsWithThumbnail(string archiveName, bool visible, int skip, int take, out int docunentsInArchiveCount)
    {
        docunentsInArchiveCount = -1;
        try
        {
            logger.DebugFormat("GetAllDocuments archiveName:{0}, skip:{1}, take:{2}, visible:{3}", archiveName, skip, take, visible);
            var archive = ArchiveService.GetArchiveByName(archiveName);
            if (archive == null)
            {
                throw new BiblosDS.Library.Common.Exceptions.Archive_Exception("Archive: " + archiveName + " not found.");
            }
            var result = DocumentService.GetAllDocuments(archive, visible, skip, take, out docunentsInArchiveCount);

            using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName))
            {
                foreach (var item in result)
                {
                    if (!string.IsNullOrEmpty(item.IdThumbnail))
                    {
                        item.ThumbnailContent = (clientChannel as IServiceDocumentStorage).GetDocumentConformAttach(item, item.IdThumbnail).Content;
                    }
                }
            }
            return(result);
        }
        catch (Exception ex)
        {
            logger.Error(ex);
            throw;
        }
        finally
        {
            logger.DebugFormat("GetAllDocuments archiveName:{0}, RETUNT: {1}", archiveName, docunentsInArchiveCount);
        }
    }
        public ActionResult Index()
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                PreservationVerifyIndexModel model = new PreservationVerifyIndexModel();
                CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel;

                if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false")
                {
                    DocumentCondition conditions = new DocumentCondition();

                    List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>();
                    conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>();
                    conditions.DocumentAttributeConditions.Add(new DocumentCondition()
                    {
                        Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And
                    });
                    sortConditions.Add(new DocumentSortCondition {
                        Name = "Name", Dir = "ASC"
                    });

                    model.archives = ArchiveService.GetArchives(0, int.MaxValue, conditions, sortConditions, out int total, customerCompany.CompanyId).ToList();
                }
                else
                {
                    model.archives = UserArchive.GetUserArchivesPaged(User.Identity.Name, 0, int.MaxValue, out int total, customerCompany.CompanyId);
                }

                return View(model);
            }, _loggerService));
        }
예제 #4
0
        public ActionResult GetPreservationPendingTask([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = new DataSourceResult();

            CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel;

            ICollection <PreservationTask> items = new List <PreservationTask>();

            try
            {
                BindingList <DocumentArchive> archives = null;
                if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false")
                {
                    archives = new BindingList <DocumentArchive>(ArchiveService.GetLegalArchives("", customerCompany.CompanyId).Select(x => x.Archive).ToList());
                }
                else
                {
                    archives = CustomerService.GetCustomerArchivesByUsername(User.Identity.Name);
                }
                items        = _preservationService.GetPreservationActiveTasks(archives.Select(s => s.IdArchive).ToList());
                result.Total = items.Count;
                result.Data  = items;
            }
            catch (Exception ex)
            {
                result.Errors = ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        private void InitWCFHost()
        {
            _host = WCFUtility.CreateWCFHost <AnalyzeTask>
                    (
                BaseAddress,
                new NetTcpBinding(SecurityMode.None)
            {
                CloseTimeout           = TimeSpan.FromDays(3),
                MaxReceivedMessageSize = _maxRecvMessageSize,
                OpenTimeout            = TimeSpan.FromDays(3),
                ReceiveTimeout         = TimeSpan.FromDays(3),
                SendTimeout            = TimeSpan.FromDays(3),
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max,
            },
                true);
            _host.Opened += new EventHandler(host_Opened);
            _host.Open();
            _analyzeTaskSvc = (AnalyzeTask)_host.SingletonInstance;
            //启动分析线程
            Thread thread = new Thread(ProcessBackAnalyzeTask);

            thread.Name = "AnalyzeTask";
            thread.Start();
            _backGroundTaskFactory = new TaskFactory(TaskScheduler.Default);

            //_host.MonitorCall += new EventHandler<MonitorInfoEventArgs>(Process_MonitorCall);
        }
예제 #6
0
 public void AddStorage(DocumentStorage Storage)
 {
     StorageService.AddStorage(Storage);
     using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName))
     {
         (clientChannel as IServiceDocumentStorage).InitializeStorage(Storage);
     }
 }
예제 #7
0
        public static DocumentServer AddDocumentToMaster(Document document)
        {
            var server = ServerService.GetCurrentServer();

            if (server == null)
            {
                throw new Exceptions.ServerNotDefined_Exception();
            }
            string         pathTransito = ServerService.GetPathTransito(document.Archive, server.IdServer);
            DocumentStatus status       = DocumentStatus.Undefined;

            if (document.Archive.TransitoEnabled)
            {
                if ((document.Content != null && document.Content.Blob != null && document.Content.Blob.Length > 0))
                {
                    FileService.SaveFileToTransitoLocalPath(document, pathTransito, document.Content.Blob);
                    status = DocumentStatus.InTransito;
                }
                else
                {
                    if (ConfigurationManager.AppSettings["AllowZeroByteDocument"].ToStringExt() != "true")
                    {
                        throw new Exception("Impossibile inserire un documento di zero byte.");
                    }
                    else
                    {
                        status = DocumentStatus.ProfileOnly;
                    }
                }
            }
            else
            {
                if ((document.Content != null && document.Content.Blob != null && document.Content.Blob.Length > 0))
                {
                    using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName, server.ServerName))
                    {
                        (clientChannel as IServiceDocumentStorage).AddDocument(document);
                    }
                    status = DocumentStatus.InStorage;
                }
                else
                {
                    if (ConfigurationManager.AppSettings["AllowZeroByteDocument"].ToStringExt() != "true")
                    {
                        throw new Exception("Impossibile inserire un documento di zero byte.");
                    }
                    else
                    {
                        status = DocumentStatus.ProfileOnly;
                    }
                }
            }
            document.Storage     = null;
            document.StorageArea = null;
            return(DbProvider.SaveDocumentToMaster(document, server, status, pathTransito));
        }
예제 #8
0
    public bool StoreTransitArchiveDocumentAttaches(string archiveName)
    {
        bool bReturn = true;

        try
        {
            DocumentArchive archive = ArchiveService.GetArchiveByName(archiveName);
            if (archive == null)
            {
                throw new BiblosDS.Library.Common.Exceptions.Archive_Exception("Archive not found");
            }


            BindingList <DocumentAttach> documents = DocumentService.GetDocumentAttachesInTransito(archive.IdArchive, 0); // esegue la query nel db
            DocumentAttach document;
            foreach (var item in documents)
            {
                try
                {
                    document = DocumentService.GetDocumentAttach(item.IdDocumentAttach);
                    using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName))
                    {
                        (clientChannel as IServiceDocumentStorage).AddAttachToDocument(document);
                    }
                }
                catch (Exception e)
                {
                    bReturn = false;

                    Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                          "Document.ProcessCheckInTransitoDocumentAttach",
                                          e.ToString(),
                                          LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                          LoggingLevel.BiblosDS_Warning);
                }
            } // end foreach

            return(bReturn);
        }
        catch (Exception ex)
        {
            Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                  "Document.ProcessCheckInTransitoDocument",
                                  ex.ToString(),
                                  LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                  LoggingLevel.BiblosDS_Warning);

            return(false);
        }
    }
예제 #9
0
 private void StartService()
 {
     try
     {
         if (WCFUtility.DoesWCFServiceExist(this.GetType().FullName.ToString()))
         {
             ServiceHost callDispatcherHost = new ServiceHost(this);
             callDispatcherHost.Open();
             logger.Debug("SIPProxyDispatcher call dispatcher service started.");
         }
     }
     catch (Exception excp)
     {
         logger.Warn("Exception SIPProxyDispatcher StartService. " + excp.Message);
     }
 }
예제 #10
0
    public bool StoreTransitDocuments()
    {
        logger.Debug("StoreTransitDocuments -> Init");
        bool bReturn = true;

        try
        {
            BindingList <Document> documents = DocumentService.GetDocumentInTransito(0); // esegue la query nel db
            Document document;
            foreach (Document item in documents)
            {
                try
                {
                    document = DocumentService.GetDocument(item.IdDocument);
                    using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName))
                    {
                        (clientChannel as IServiceDocumentStorage).AddDocument(document);
                    }
                }
                catch (Exception e)
                {
                    bReturn = false;

                    Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                          "Document.ProcessCheckInTransitoDocument",
                                          e.ToString(),
                                          LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                          LoggingLevel.BiblosDS_Warning);
                }
            } // end foreach

            logger.InfoFormat("StoreTransitDocuments -> End processed {0} documents that are in 'Transito'", documents.Count);

            return(bReturn);
        }
        catch (Exception ex)
        {
            Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                  "Document.ProcessCheckInTransitoDocument",
                                  ex.ToString(),
                                  LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                  LoggingLevel.BiblosDS_Warning);

            return(false);
        }
    }
예제 #11
0
    public bool StoreTransitDocument(Guid idDocument)
    {
        bool bReturn = true;

        try
        {
            Document document;

            try
            {
                document = DocumentService.GetDocument(idDocument);
                using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName))
                {
                    (clientChannel as IServiceDocumentStorage).AddDocument(document);
                }
            }
            catch (Exception e)
            {
                bReturn = false;

                Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                      "Document.ProcessCheckInTransitoDocument",
                                      e.ToString(),
                                      LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                      LoggingLevel.BiblosDS_Warning);
            }

            logger.InfoFormat("Document.ProcessCheckInTransitoDocument processed document: {0}", idDocument);

            return(bReturn);
        }
        catch (Exception ex)
        {
            Logging.WriteLogEvent(LoggingSource.BiblosDS_WS,
                                  "Document.ProcessCheckInTransitoDocument",
                                  ex.ToString(),
                                  LoggingOperationType.BiblosDS_CheckInTransitoDocument,
                                  LoggingLevel.BiblosDS_Warning);

            return(false);
        }
    }
        public void Start()
        {
            try
            {
                logger.Debug("SIPMonitorDaemon starting...");

                if (m_monitorLoopbackListenerPort == 0)
                {
                    throw new ApplicationException("Cannot start SIP Monitor with no loopback listener port specified.");
                }

                m_sipMonitorMediator = new SIPMonitorMediator(
                    m_monitorLoopbackListenerPort,
                    null,
                    m_monitorEventPublisher);

                m_sipMonitorMediator.StartMonitoring();

                logger.Debug("The SIP Monitor Server was successfully started, loopback port " + m_monitorLoopbackListenerPort + ".");

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(SIPMonitorClientManagerHost).FullName.ToString()))
                    {
                        SIPMonitorClientManagerHost monitorClientManagerHost = new SIPMonitorClientManagerHost(m_monitorEventPublisher);
                        ServiceHost internalNotifications = new ServiceHost(monitorClientManagerHost);
                        internalNotifications.Open();

                        logger.Debug("Internal notifications hosted service successfully started on " + internalNotifications.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting internal notifications hosted service. " + excp.Message);
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorDaemon Start. " + excp.Message);
            }
        }
예제 #13
0
        public override async Task Execute(CommandModel commandModel)
        {
            try
            {
                if (!(commandModel is CommandInsertPreservationPDV))
                {
                    _logger.Error($"Command is not of type {nameof(CommandInsertPreservationPDV)}");
                    return;
                }

                CommandInsertPreservationPDV @command = commandModel as CommandInsertPreservationPDV;
                await SendNotification(command.ReferenceId, $"Inizio salvataggio PDV per il lotto di versamento con id {command.IdAwardBatch}", NotifyLevel.Info);

                DocumentArchive pdvArchive = ArchiveService.GetArchiveByName(command.PDVArchive);
                if (pdvArchive == null)
                {
                    _logger.Error($"Archive with name {command.PDVArchive} not found");
                    throw new Exception($"Non è stato trovato un archivio con nome {command.PDVArchive}");
                }

                ICollection <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(pdvArchive.IdArchive);
                AwardBatch awardBatch = _preservationService.GetAwardBatch(command.IdAwardBatch);
                if (awardBatch == null)
                {
                    _logger.Error($"Award batch with id {command.IdAwardBatch} not found");
                    throw new Exception($"Non è stato trovato un lotto di versamento con id {command.IdAwardBatch}");
                }

                Document document = new Document
                {
                    Content = new DocumentContent()
                    {
                        Blob = Convert.FromBase64String(command.Content)
                    },
                    Name            = string.Concat(UtilityService.GetSafeFileName(awardBatch.Name), ".xml"),
                    Archive         = pdvArchive,
                    AttributeValues = new BindingList <DocumentAttributeValue>()
                };
                document.AttributeValues.Add(new DocumentAttributeValue()
                {
                    Value     = document.Name,
                    Attribute = attributes.Single(f => f.Name.Equals("Filename", StringComparison.InvariantCultureIgnoreCase))
                });
                document.AttributeValues.Add(new DocumentAttributeValue()
                {
                    Value     = awardBatch.Name,
                    Attribute = attributes.Single(f => f.Name.Equals("Signature", StringComparison.InvariantCultureIgnoreCase))
                });

                using (var clientChannel = WCFUtility.GetClientConfigChannel <IDocuments>(ServerService.WCF_Document_HostName))
                {
                    document = (clientChannel as IDocuments).AddDocumentToChain(document, null, DocumentContentFormat.Binary);
                }
                awardBatch.IdPDVDocument = document.IdDocument;
                _preservationService.UpdateAwardBatch(awardBatch);
                _logger.Info($"Saved PDV with id {awardBatch.IdPDVDocument} for awardbatch {awardBatch.IdAwardBatch}");
                await SendNotification(command.ReferenceId, $"PDV salvato con id {awardBatch.IdPDVDocument} per il lotto di versamento con id {awardBatch.IdAwardBatch}", NotifyLevel.Info);
            }
            catch (Exception ex)
            {
                _logger.Error("Error on insert PDV", ex);
                await SendNotification(commandModel.ReferenceId, $"Errore nella fase di inserimento PDV", NotifyLevel.Error);
            }
        }
예제 #14
0
        public ActionResult GridArchives([DataSourceRequest] DataSourceRequest request)
        {
            var result = new DataSourceResult();

            try
            {
                int total = 0;
                int skip  = request.Page - 1;
                int take  = request.PageSize;

                skip = (skip < 1) ? 0 : skip * take;
                CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel;

                if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false")
                {
                    DocumentCondition conditions = new DocumentCondition();

                    List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>();
                    conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>();
                    conditions.DocumentAttributeConditions.Add(new DocumentCondition()
                    {
                        Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And
                    });

                    if (request.Filters != null)
                    {
                        foreach (var item in request.Filters)
                        {
                            //conditions.DocumentAttributeConditions.Add(new DocumentCondition { Name = item., Value = item.Value, Operator = Library.Common.Enums.DocumentConditionFilterOperator.Contains, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And });
                        }
                    }

                    if (request.Sorts != null)
                    {
                        foreach (var item in request.Sorts)
                        {
                            sortConditions.Add(new DocumentSortCondition {
                                Name = item.Member, Dir = item.SortDirection
                            });
                        }
                    }
                    else
                    {
                        sortConditions.Add(new DocumentSortCondition {
                            Name = "Name", Dir = "ASC"
                        });
                    }


                    result.Data = ArchiveService.GetArchives(skip, take, conditions, sortConditions, out total, customerCompany.CompanyId).ToList();
                }
                else
                {
                    result.Data = UserArchive.GetUserArchivesPaged(User.Identity.Name, skip, take, out total, customerCompany.CompanyId);
                }

                result.Total = total;
            }
            catch (Exception ex)
            {
                result.Errors = ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        public void Start()
        {
            try
            {
                logger.Debug("pid=" + Process.GetCurrentProcess().Id + ".");
                logger.Debug("os=" + System.Environment.OSVersion + ".");
                logger.Debug("current directory=" + m_currentDirectory + ".");
                logger.Debug("base directory=" + AppDomain.CurrentDomain.BaseDirectory + ".");

                SIPDNSManager.SIPMonitorLogEvent = FireSIPMonitorEvent;
                m_sipSorceryPersistor            = new SIPSorceryPersistor(m_storageType, m_connectionString);
                m_customerSessionManager         = new CustomerSessionManager(m_storageType, m_connectionString);
                m_cdrDataLayer = new Entities.CDRDataLayer();

                if (m_sipProxyEnabled)
                {
                    m_sipProxyDaemon = new SIPProxyDaemon();
                    m_sipProxyDaemon.Start();

                    if (m_sipProxyDaemon.PublicIPAddress != null)
                    {
                        m_publicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        DialStringParser.PublicIPAddress     = m_sipProxyDaemon.PublicIPAddress;
                        DialPlanScriptFacade.PublicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        SIPDialogueManager.PublicIPAddress   = m_sipProxyDaemon.PublicIPAddress;
                    }
                    else
                    {
                        m_sipProxyDaemon.PublicIPAddressUpdated += (ipAddress) =>
                        {
                            if (ipAddress != null && (m_publicIPAddress == null || ipAddress.ToString() != m_publicIPAddress.ToString()))
                            {
                                m_publicIPAddress = ipAddress;
                                DialStringParser.PublicIPAddress     = ipAddress;
                                DialPlanScriptFacade.PublicIPAddress = ipAddress;
                                SIPDialogueManager.PublicIPAddress   = ipAddress;
                            }
                        };
                    }
                }

                if (m_sipMonitorEnabled)
                {
                    m_sipMonitorPublisher = new SIPMonitorClientManager(null);
                    m_sipMonitorDaemon    = new SIPMonitorDaemon(m_sipMonitorPublisher);
                    m_sipMonitorDaemon.Start();
                }

                if (m_sipRegistrarEnabled)
                {
                    m_sipRegistrarDaemon = new SIPRegistrarDaemon(
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_customerSessionManager.CustomerPersistor);
                    m_sipRegistrarDaemon.Start();
                }

                if (m_sipRegAgentEnabled)
                {
                    m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                        m_sipSorceryPersistor.SIPProvidersPersistor,
                        m_sipSorceryPersistor.SIPProviderBindingsPersistor);

                    m_sipRegAgentDaemon.Start();
                }

                if (m_sipNotifierEnabled)
                {
                    m_sipNotifierDaemon = new SIPNotifierDaemon(
                        m_customerSessionManager.CustomerPersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Count,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_sipMonitorPublisher);
                    //new SIPMonitorUDPSink("127.0.0.1:10003"));
                    m_sipNotifierDaemon.Start();
                }

                if (m_sshServerEnabled)
                {
                    SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, m_sipMonitorPublisher); // Uses memory to transfer events.
                    //SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, new SIPMonitorUDPSink("127.0.0.1:10002"));
                    daemon.Start();
                }

                #region Initialise the SIP Application Server and its logging mechanisms including CDRs.

                logger.Debug("Initiating SIP Application Server Agent.");

                // Send events from this process to the monitoring socket.
                if (m_monitorEventLoopbackPort != 0)
                {
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorEventLoopbackPort);
                }

                if (m_cdrDataLayer != null)
                {
                    SIPCDR.CDRCreated  += m_cdrDataLayer.Add;
                    SIPCDR.CDRAnswered += m_cdrDataLayer.Update;
                    SIPCDR.CDRHungup   += m_cdrDataLayer.Update;
                    SIPCDR.CDRUpdated  += m_cdrDataLayer.Update;
                }

                #region Initialise the SIPTransport layers.

                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), true);
                if (m_appServerEndPoint != null)
                {
                    if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.udp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPUDPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.tcp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPTCPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else
                    {
                        throw new ApplicationException("The SIP End Point of " + m_appServerEndPoint + " cannot be used with the App Server transport layer.");
                    }
                }
                else if (m_sipAppServerSocketsNode != null)
                {
                    m_sipTransport.AddSIPChannel(SIPTransportConfig.ParseSIPChannelsNode(m_sipAppServerSocketsNode));
                }
                else
                {
                    throw new ApplicationException("The SIP App Server could not be started, no SIP sockets have been configured.");
                }

                m_sipTransport.SIPRequestInTraceEvent     += LogSIPRequestIn;
                m_sipTransport.SIPRequestOutTraceEvent    += LogSIPRequestOut;
                m_sipTransport.SIPResponseInTraceEvent    += LogSIPResponseIn;
                m_sipTransport.SIPResponseOutTraceEvent   += LogSIPResponseOut;
                m_sipTransport.SIPBadRequestInTraceEvent  += LogSIPBadRequestIn;
                m_sipTransport.SIPBadResponseInTraceEvent += LogSIPBadResponseIn;

                #endregion

                m_dialPlanEngine = new DialPlanEngine(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor,
                    //m_sipSorceryPersistor.SIPAccountsPersistor,
                    //m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    //m_sipSorceryPersistor.SIPDialPlanPersistor,
                    //m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_outboundProxy,
                    m_rubyScriptCommonPath,
                    m_dialplanImpersonationUsername,
                    m_dialplanImpersonationPassword,
                    m_maxDialPlanExecutionLimit);

                m_sipDialogueManager = new SIPDialogueManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain);

                m_callManager = new SIPCallManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    m_dialPlanEngine,
                    m_sipSorceryPersistor.SIPDialPlanPersistor.Get,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    m_sipSorceryPersistor.SIPProvidersPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    m_customerSessionManager.CustomerPersistor,
                    m_sipSorceryPersistor.SIPDialPlanPersistor,
                    m_traceDirectory,
                    m_monitorCalls,
                    m_dailyCallLimit);
                m_callManager.Start();

                m_appServerCore = new SIPAppServerCore(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    FireSIPMonitorEvent,
                    m_callManager,
                    m_sipDialogueManager,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_outboundProxy);

                m_rtccCore = new RTCCCore(
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor);
                m_rtccCore.Start();

                m_rateUpdater = new RateBulkUpdater(FireSIPMonitorEvent);
                m_rateUpdater.Start();

                #endregion

                #region Initialise WCF services.

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(SIPProvisioningWebService).FullName.ToString()))
                    {
                        if (m_sipSorceryPersistor == null)
                        {
                            logger.Warn("Provisioning hosted service could not be started as Persistor object was null.");
                        }
                        else
                        {
                            SIPProviderBindingSynchroniser sipProviderBindingSynchroniser = new SIPProviderBindingSynchroniser(m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            m_sipSorceryPersistor.SIPProvidersPersistor.Added   += sipProviderBindingSynchroniser.SIPProviderAdded;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Updated += sipProviderBindingSynchroniser.SIPProviderUpdated;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Deleted += sipProviderBindingSynchroniser.SIPProviderDeleted;

                            ProvisioningServiceInstanceProvider instanceProvider = new ProvisioningServiceInstanceProvider(
                                m_sipSorceryPersistor.SIPAccountsPersistor,
                                m_sipSorceryPersistor.SIPDialPlanPersistor,
                                m_sipSorceryPersistor.SIPProvidersPersistor,
                                m_sipSorceryPersistor.SIPProviderBindingsPersistor,
                                m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                                m_sipSorceryPersistor.SIPDialoguePersistor,
                                m_sipSorceryPersistor.SIPCDRPersistor,
                                m_customerSessionManager,
                                m_sipSorceryPersistor.SIPDomainManager,
                                FireSIPMonitorEvent,
                                0,
                                false);

                            m_sipProvisioningHost = new ServiceHost(typeof(SIPProvisioningWebService));
                            m_sipProvisioningHost.Description.Behaviors.Add(instanceProvider);
                            m_sipProvisioningHost.Open();

                            if (m_sipRegAgentDaemon == null)
                            {
                                m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                                    m_sipSorceryPersistor.SIPProvidersPersistor,
                                    m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            }

                            logger.Debug("Provisioning hosted service successfully started on " + m_sipProvisioningHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting Provisioning hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CrossDomainService).FullName.ToString()))
                    {
                        m_accessPolicyHost = new ServiceHost(typeof(CrossDomainService));
                        m_accessPolicyHost.Open();

                        logger.Debug("CrossDomain hosted service successfully started on " + m_accessPolicyHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CrossDomain hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CallManagerServices).FullName.ToString()))
                    {
                        CallManagerServiceInstanceProvider callManagerSvcInstanceProvider = new CallManagerServiceInstanceProvider(m_callManager, m_sipDialogueManager);

                        Uri callManagerBaseAddress = null;
                        if (m_callManagerServiceAddress != null)
                        {
                            logger.Debug("Adding service address to Call Manager Service " + m_callManagerServiceAddress + ".");
                            callManagerBaseAddress = new Uri(m_callManagerServiceAddress);
                        }

                        if (callManagerBaseAddress != null)
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices), callManagerBaseAddress);
                        }
                        else
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices));
                        }

                        m_callManagerSvcHost.Description.Behaviors.Add(callManagerSvcInstanceProvider);

                        m_callManagerSvcHost.Open();

                        logger.Debug("CallManager hosted service successfully started on " + m_callManagerSvcHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CallManager hosted service. " + excp.Message);
                }

                if (WCFUtility.DoesWCFServiceExist(typeof(SIPNotifierService).FullName.ToString()))
                {
                    if (m_sipMonitorPublisher != null)
                    {
                        try
                        {
                            SIPNotifierService notifierService = new SIPNotifierService(m_sipMonitorPublisher, m_customerSessionManager);
                            m_sipNotificationsHost = new ServiceHost(notifierService);

                            m_sipNotificationsHost.Open();

                            logger.Debug("SIPNotificationsService hosted service successfully started on " + m_sipNotificationsHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                        catch (Exception excp)
                        {
                            logger.Warn("Exception starting SIPNotificationsService hosted service. " + excp.Message);
                        }
                    }
                }

                #endregion
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPAppServerDaemon Start. " + excp.Message);
                throw excp;
            }
        }
예제 #16
0
        public ActionResult GridPreservationVerify([DataSourceRequest] DataSourceRequest request)
        {
            var result = new DataSourceResult();

            try
            {
                int total = 0;
                int skip  = (request.Page - 1) * request.PageSize;
                int take  = request.PageSize;

                if (skip < 0)
                {
                    skip = 0;
                }

                var service = new PreservationService();

                const int ARCHIVES_TAKE = 5;
                int       archiveSkip = 0, totalArchives;

                List <DocumentArchive>   archivi         = null;
                CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel;

                if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false")
                {
                    DocumentCondition            conditions     = new DocumentCondition();
                    List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>();
                    conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>();
                    conditions.DocumentAttributeConditions.Add(new DocumentCondition()
                    {
                        Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And
                    });
                    if (request.Filters != null)
                    {
                        foreach (var item in request.Filters)
                        {
                            //conditions.DocumentAttributeConditions.Add(new DocumentCondition { Name = item., Value = item.Value, Operator = Library.Common.Enums.DocumentConditionFilterOperator.Contains, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And });
                        }
                    }
                    if (request.Sorts != null)
                    {
                        foreach (var item in request.Sorts)
                        {
                            sortConditions.Add(new DocumentSortCondition {
                                Name = item.Member, Dir = item.SortDirection
                            });
                        }
                    }
                    else
                    {
                        sortConditions.Add(new DocumentSortCondition {
                            Name = "Name", Dir = "ASC"
                        });
                    }

                    archivi = ArchiveService.GetArchives(skip, take, conditions, sortConditions, out total, customerCompany.CompanyId).ToList();
                }
                else
                {
                    archivi = UserArchive.GetUserArchivesPaged(User.Identity.Name, archiveSkip, ARCHIVES_TAKE, out totalArchives, customerCompany.CompanyId);

                    if (archivi.Count < totalArchives)
                    {
                        for (archiveSkip += ARCHIVES_TAKE; archiveSkip < totalArchives; archiveSkip += ARCHIVES_TAKE)
                        {
                            archivi.AddRange(UserArchive.GetUserArchivesPaged(User.Identity.Name, archiveSkip, ARCHIVES_TAKE, out totalArchives, customerCompany.CompanyId));
                        }
                    }

                    if (archivi.Any())
                    {
                        result.Data = service.GetPreservationVerify(archivi.Select(x => x.IdArchive).ToArray <Guid>(), skip, take, out total, null);
                    }
                    else
                    {
                        result.Data = archivi;
                    }
                }
                result.Total = total;
            }
            catch (Exception ex)
            {
                result.Errors = ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public void Start()
        {
            try
            {
                logger.Debug("pid=" + Process.GetCurrentProcess().Id + ".");
                logger.Debug("os=" + System.Environment.OSVersion + ".");
                logger.Debug("current directory=" + m_currentDirectory + ".");
                logger.Debug("base directory=" + AppDomain.CurrentDomain.BaseDirectory + ".");

                SIPDNSManager.SIPMonitorLogEvent = FireSIPMonitorEvent;
                m_sipSorceryPersistor            = new SIPSorceryPersistor(m_storageType, m_connectionString);
                m_customerSessionManager         = new CustomerSessionManager(m_storageType, m_connectionString);
                m_cdrDataLayer = new Entities.CDRDataLayer();

                #region Initialise the SIP Application Server and its logging mechanisms including CDRs.

                logger.Debug("Initiating SIP Application Server Agent.");

                // Send events from this process to the monitoring socket.
                if (m_monitorEventLoopbackPort != 0)
                {
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorEventLoopbackPort);
                }

                if (m_cdrDataLayer != null)
                {
                    SIPCDR.CDRCreated  += m_cdrDataLayer.Add;
                    SIPCDR.CDRAnswered += m_cdrDataLayer.Update;
                    SIPCDR.CDRHungup   += m_cdrDataLayer.Update;
                    SIPCDR.CDRUpdated  += m_cdrDataLayer.Update;
                }

                #region Initialise the SIPTransport layers.

                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), true);
                if (m_appServerEndPoint != null)
                {
                    if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.udp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPUDPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.tcp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPTCPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else
                    {
                        throw new ApplicationException("The SIP End Point of " + m_appServerEndPoint + " cannot be used with the App Server transport layer.");
                    }
                }
                else if (m_sipAppServerSocketsNode != null)
                {
                    m_sipTransport.AddSIPChannel(SIPTransportConfig.ParseSIPChannelsNode(m_sipAppServerSocketsNode));
                }
                else
                {
                    throw new ApplicationException("The SIP App Server could not be started, no SIP sockets have been configured.");
                }

                m_sipTransport.SIPRequestInTraceEvent     += LogSIPRequestIn;
                m_sipTransport.SIPRequestOutTraceEvent    += LogSIPRequestOut;
                m_sipTransport.SIPResponseInTraceEvent    += LogSIPResponseIn;
                m_sipTransport.SIPResponseOutTraceEvent   += LogSIPResponseOut;
                m_sipTransport.SIPBadRequestInTraceEvent  += LogSIPBadRequestIn;
                m_sipTransport.SIPBadResponseInTraceEvent += LogSIPBadResponseIn;

                #endregion

                m_dialPlanEngine = new DialPlanEngine(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor,
                    m_outboundProxy,
                    m_rubyScriptCommonPath,
                    m_dialplanImpersonationUsername,
                    m_dialplanImpersonationPassword,
                    m_maxDialPlanExecutionLimit);

                m_sipDialogueManager = new SIPDialogueManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain);

                m_callManager = new SIPCallManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    m_dialPlanEngine,
                    m_sipSorceryPersistor.SIPDialPlanPersistor.Get,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    m_sipSorceryPersistor.SIPProvidersPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    m_customerSessionManager.CustomerPersistor,
                    m_sipSorceryPersistor.SIPDialPlanPersistor,
                    m_traceDirectory,
                    m_monitorCalls,
                    m_dailyCallLimit);
                m_callManager.Start();

                GetSIPAccountDelegate getSIPAccount = (username, domain) => {
                    return(m_sipSorceryPersistor.SIPAccountsPersistor.Get(x => x.SIPUsername == username && x.SIPDomain == domain).SIPAccount);
                };

                m_appServerCore = new SIPAppServerCore(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    getSIPAccount,
                    FireSIPMonitorEvent,
                    m_callManager,
                    m_sipDialogueManager,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_outboundProxy);

                #endregion

                #region Initialise WCF services.

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CallManagerServices).FullName.ToString()))
                    {
                        CallManagerServiceInstanceProvider callManagerSvcInstanceProvider = new CallManagerServiceInstanceProvider(m_callManager, m_sipDialogueManager);

                        Uri callManagerBaseAddress = null;
                        if (m_callManagerServiceAddress != null)
                        {
                            logger.Debug("Adding service address to Call Manager Service " + m_callManagerServiceAddress + ".");
                            callManagerBaseAddress = new Uri(m_callManagerServiceAddress);
                        }

                        if (callManagerBaseAddress != null)
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices), callManagerBaseAddress);
                        }
                        else
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices));
                        }

                        m_callManagerSvcHost.Description.Behaviors.Add(callManagerSvcInstanceProvider);

                        m_callManagerSvcHost.Open();

                        logger.Debug("CallManager hosted service successfully started on " + m_callManagerSvcHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CallManager hosted service. " + excp.Message);
                }

                #endregion
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPAppServerDaemon Start. " + excp.Message);
                throw excp;
            }
        }