/// <summary>
        /// Выполнить команду
        /// </summary>
        protected override async Task InternalExecute(Channel channel, StasisStartEventArgs args)
        {
            if (!(args is IsolationStasisStartEventArgs model))
            {
                return;
            }

            var isolationData = model.IsolationStatusData;

            try
            {
                var isolationChannel = await ChannelRepository.GetChannelByCallId(isolationData.CallId);

                if (isolationData.Isolated)
                {
                    await AriClient.MuteChannel(isolationChannel.ChannelId);
                }
                else
                {
                    await AriClient.UnmuteChannel(isolationChannel.ChannelId);
                }
            }
            catch (Exception ex)
            {
                Logger.Warning(ex.Message);
                throw new Exception($"Не удалось установить параметр изоляции со значением {isolationData.Isolated}");
            }
        }
예제 #2
0
        public ActionResult CCL2()
        {
            var collectors = CollectorRepository.GetAll();

            collectors.Insert(0, new Domain.Collectors.CollectorInfo {
                CollectorId = 0, Name = "Tất cả"
            });
            ViewBag.Collectors = collectors;
            var channels = ChannelRepository.GetAll();

            channels.Insert(0, new Domain.Channels.ChannelInfo {
                ChannelId = 0, Name = "Tất cả"
            });
            ViewBag.Channels = channels;
            var imports = ImportExcelRepository.GetAll();

            foreach (Domain.ImportExcels.ImportExcelInfo info in imports)
            {
                if (!string.IsNullOrEmpty(info.FilePath))
                {
                    int index = info.FilePath.LastIndexOf("\\");
                    if (index > -1)
                    {
                        info.FilePath = info.FilePath.Substring(index);
                    }
                }
            }
            imports.Insert(0, new Domain.ImportExcels.ImportExcelInfo {
                ImportId = 0, FilePath = "Tất cả"
            });
            ViewBag.ImportExcels = imports;
            return(View());
        }
예제 #3
0
        //Lay danh sach CC
        public ActionResult CCL0()
        {
            // Collectors
            var collectors = CollectorRepository.GetAll();

            ViewBag.Collectors = collectors;

            // LevelCCs
            ViewBag.LevelCCs = StoreData.ListLevel.Where(x => x.LevelId < 3).ToList();

            // ChannelCCs
            var channels = ChannelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC);

            ViewBag.ChannelCCs = channels;

            // ImportExcelCCs
            var importExcels = ImportExcelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC);

            foreach (var item in importExcels)
            {
                item.FilePath = (new FileInfo(item.FilePath)).Name;
            }
            ViewBag.ImportExcelCCs = importExcels;
            return(View());
        }
예제 #4
0
        /// <inheritdoc />
        protected override async Task InternalExecute(Channel channel, StasisStartEventArgs args)
        {
            var lineId = args.RouteData?.LineId;

            if (!lineId.HasValue)
            {
                Logger.Warning("SwitchRolesCommand. Не найден LineId.");
                throw new Exception("Не найден LineId");
            }

            var oldMainChannel = await ChannelRepository.GetChannelForMainUser(lineId.Value);

            if (oldMainChannel == null)
            {
                Logger.Warning("SwitchRolesCommand. Не найден канал главного в разговоре.");
                throw new Exception("Не найден канал главного в разговоре");
            }

            if (oldMainChannel.CallId != args.RouteData.FromCallId)
            {
                Logger.Warning($"SwitchRolesCommand. Пользователь звонка {args.RouteData.FromCallId} не является главным в разговоре. MainUserCallId: {oldMainChannel.CallId}");
                throw new Exception($"Пользователь звонка с Id {args.RouteData.FromCallId} не является главным в разговоре");
            }

            var assistantChannel = await ChannelRepository.GetChannelByCallId(args.RouteData.ToCallId);

            if (assistantChannel == null)
            {
                Logger.Warning($"SwitchRolesCommand. Канал с Id {args.RouteData.ToCallId} не найден.");
                throw new Exception($"Канал с Id {args.RouteData.ToCallId} не найден.");
            }

            await ChangeMainChannel(oldMainChannel, assistantChannel, lineId.Value, args);
        }
예제 #5
0
        /// <summary>
        /// Выполнить команду
        /// </summary>
        protected override async Task InternalExecute(Channel channel, StasisStartEventArgs args)
        {
            if (!(args is MuteStasisEventArgs model))
            {
                throw new ArgumentException($"Не правильный тип аргумента {nameof(args)}");
            }

            var muteStatusData = model.MuteStatusData;

            try
            {
                var muteChannel = await ChannelRepository.GetChannelByCallId(muteStatusData.CallId);

                if (muteStatusData.Muted)
                {
                    await AriClient.MuteChannel(muteChannel.ChannelId, "in");
                }
                else
                {
                    await AriClient.UnmuteChannel(muteChannel.ChannelId, "in");
                }
            }
            catch (Exception ex)
            {
                Logger.Warning(ex.Message);
                throw new Exception($"Не удалось установить параметр мюте со значением {model.MuteStatusData.Muted}");
            }
        }
        private async Task DestroyBridge(string bridgeId)
        {
            Logger.Information($"DestroyBridge: {bridgeId}");

            var allChannelsInBridge = await ChannelRepository.GetByBridgeId(bridgeId);

            if (allChannelsInBridge.Count > 1)
            {
                Logger.Debug("Bridge contains more than 1 channel");
                return;
            }

            if (allChannelsInBridge.Count == 1)
            {
                var lastChannelInBridge = allChannelsInBridge.First();
                if (lastChannelInBridge.Interrupted)
                {
                    Logger.Information($"Канал {lastChannelInBridge.ChannelId} {lastChannelInBridge.Role} ожидает ответа.");
                    return;
                }

                await AriClient.HangupChannel(lastChannelInBridge.ChannelId);

                return;
            }

            AriClient.DestroyBridge(bridgeId);
            await DestroyRecordingBridge(bridgeId);
        }
예제 #7
0
파일: BC10Model.cs 프로젝트: HungNV88/CRM
        public static List <BC10Model> CreateBc10Model(List <ContactInfo> infos)
        {
            var objModels = Create <BC10Model>(infos);

            foreach (var objModel in objModels)
            {
                var info = infos.FirstOrDefault(c => c.Id == objModel.Id);
                if (info == null)
                {
                    continue;
                }

                // Collaborator
                var collaborator = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId);
                if (collaborator != null)
                {
                    objModel.Collaborator = collaborator.FullName;
                }

                var channel = ChannelRepository.GetAll().FirstOrDefault(c => c.ChannelId == info.ChannelId);
                if (channel != null)
                {
                    objModel.Channel = channel.Name;
                }
            }

            return(objModels);
        }
        /// <inheritdoc />
        protected override async Task InternalExecute(Channel incomingCallChannel, StasisStartEventArgs args)
        {
            var callerExtension = incomingCallChannel.Caller.Number;
            var callId          = Guid.NewGuid();

            var mainBridge = await InitializeMainBridge(incomingCallChannel.Id, callerExtension, callId);

            if (mainBridge == null)
            {
                return;
            }

            var channel = new DAL.Entities.Channel
            {
                ChannelId = incomingCallChannel.Id,
                Extension = callerExtension,
                CallId    = callId,
                BridgeId  = mainBridge,
                Role      = ChannelRoleType.ExternalChannel
            };

            var bNumber = incomingCallChannel.Dialplan.Exten;
            await _queueSender.Publish(new IncomingCallIntegrationEvent
            {
                CallId          = callId,
                CallerExtension = callerExtension,
                BNumber         = bNumber,
            });

            Logger.Information($"Sent message to queue about incoming call. Caller: {callerExtension}; ChannelId: {incomingCallChannel.Id}");

            await ChannelRepository.AddChannel(channel);
        }
예제 #9
0
        public async void AddAndVerifyChannels()
        {
            // Arrange
            using (var scope = _container.BeginLifetimeScope())
            {
                var mediator = scope.Resolve <IMediator>();

                using (var ctx = new GossipContext())
                    using (var uow = await new UnitOfWorkFactory <GossipContext>(ctx, mediator).CreateAsync())
                    {
                        var channelRepo = new ChannelRepository(ctx);
                        ctx.Channels.RemoveRange(ctx.Channels);

                        // Act
                        channelRepo.InsertChannel(new Channel(name: "abc", description: "def"));
                        await uow.CommitChangesAsync();

                        var channels = await channelRepo.GetAllChannels();

                        // Assert
                        Assert.Collection(channels, p =>
                        {
                            Assert.Equal("abc", p.Name);
                            Assert.Equal("def", p.Description);
                        });
                    }
            }
        }
예제 #10
0
        public OctopusAsyncRepository(IOctopusAsyncClient client, RepositoryScope repositoryScope = null)
        {
            Client                    = client;
            Scope                     = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                  = new AccountRepository(this);
            ActionTemplates           = new ActionTemplateRepository(this);
            Artifacts                 = new ArtifactRepository(this);
            Backups                   = new BackupRepository(this);
            BuiltInPackageRepository  = new BuiltInPackageRepositoryRepository(this);
            CertificateConfiguration  = new CertificateConfigurationRepository(this);
            Certificates              = new CertificateRepository(this);
            Channels                  = new ChannelRepository(this);
            CommunityActionTemplates  = new CommunityActionTemplateRepository(this);
            Configuration             = new ConfigurationRepository(this);
            DashboardConfigurations   = new DashboardConfigurationRepository(this);
            Dashboards                = new DashboardRepository(this);
            Defects                   = new DefectsRepository(this);
            DeploymentProcesses       = new DeploymentProcessRepository(this);
            Deployments               = new DeploymentRepository(this);
            Environments              = new EnvironmentRepository(this);
            Events                    = new EventRepository(this);
            FeaturesConfiguration     = new FeaturesConfigurationRepository(this);
            Feeds                     = new FeedRepository(this);
            Interruptions             = new InterruptionRepository(this);
            LibraryVariableSets       = new LibraryVariableSetRepository(this);
            Lifecycles                = new LifecyclesRepository(this);
            MachinePolicies           = new MachinePolicyRepository(this);
            MachineRoles              = new MachineRoleRepository(this);
            Machines                  = new MachineRepository(this);
            Migrations                = new MigrationRepository(this);
            OctopusServerNodes        = new OctopusServerNodeRepository(this);
            PerformanceConfiguration  = new PerformanceConfigurationRepository(this);
            PackageMetadataRepository = new PackageMetadataRepository(this);
            ProjectGroups             = new ProjectGroupRepository(this);
            Projects                  = new ProjectRepository(this);
            ProjectTriggers           = new ProjectTriggerRepository(this);
            Proxies                   = new ProxyRepository(this);
            Releases                  = new ReleaseRepository(this);
            RetentionPolicies         = new RetentionPolicyRepository(this);
            Schedulers                = new SchedulerRepository(this);
            ServerStatus              = new ServerStatusRepository(this);
            Spaces                    = new SpaceRepository(this);
            Subscriptions             = new SubscriptionRepository(this);
            TagSets                   = new TagSetRepository(this);
            Tasks                     = new TaskRepository(this);
            Teams                     = new TeamsRepository(this);
            Tenants                   = new TenantRepository(this);
            TenantVariables           = new TenantVariablesRepository(this);
            UserInvites               = new UserInvitesRepository(this);
            UserRoles                 = new UserRolesRepository(this);
            Users                     = new UserRepository(this);
            VariableSets              = new VariableSetRepository(this);
            Workers                   = new WorkerRepository(this);
            WorkerPools               = new WorkerPoolRepository(this);
            ScopedUserRoles           = new ScopedUserRoleRepository(this);
            UserPermissions           = new UserPermissionsRepository(this);

            loadRootResource      = new Lazy <Task <RootResource> >(LoadRootDocumentInner, true);
            loadSpaceRootResource = new Lazy <Task <SpaceRootResource> >(LoadSpaceRootDocumentInner, true);
        }
예제 #11
0
        public async void AddAndVerifyChannels()
        {
            // Arrange
            using (var scope = _container.BeginLifetimeScope())
            {
                var mediator = scope.Resolve <IMediator>();
                using (var ctx = new GossipContext(mediator))
                {
                    var channelRepo = new ChannelRepository(ctx);
                    ctx.Channels.RemoveRange(ctx.Channels);

                    // Act
                    channelRepo.InsertChannel(new Channel(name: "abc", description: "def"));
                    await channelRepo.UnitOfWork.SaveEntitiesAsync();

                    var channels = await channelRepo.GetAllChannels();

                    // Assert
                    Assert.Collection(channels, p =>
                    {
                        Assert.Equal(p.Name, "abc");
                        Assert.Equal(p.Description, "def");
                    });
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Добавить snoop-копию канала во все бриджи ассистентов и в бридж для частичных ассистентов
        /// </summary>
        protected async Task SnoopChannelByAllAssistantsChannels(
            string channelId,
            string channelExtension,
            ChannelRoleType channelRole,
            Guid callId,
            StasisStartEventArgs args,
            string excludedChannelId = null)
        {
            if (args.RouteData.LineId.HasValue)
            {
                var channelsInLine = (await ChannelRepository.GetChannelsByLineId(args.RouteData.LineId.Value))
                                     .Where(t => excludedChannelId == null || t.ChannelId != excludedChannelId)
                                     .ToList();

                await SnoopChannelByAssistantChannels(channelId, channelExtension, channelRole, callId, channelsInLine, args);

                var partialAssistantChannels = channelsInLine.Where(t => t.Role == ChannelRoleType.PartialAssistant);
                foreach (var channel in partialAssistantChannels)
                {
                    await InitializeSnoopChannel(channelId, channelExtension, channelRole, callId, channel.BridgeId, args, SnoopBridgeType.Listen);

                    var speakChannel = channelsInLine.SingleOrDefault(t => t.OriginalChannelId == channel.ChannelId && t.Role == ChannelRoleType.SpeakSnoopChannel);
                    if (speakChannel != null)
                    {
                        await InitializeSnoopChannel(channelId, channelExtension, channelRole, callId, speakChannel.BridgeId, args, SnoopBridgeType.Speak);
                    }
                }
            }
        }
예제 #13
0
 public UnitOfWork()
 {
     _dbContext        = new ApplicationDbContext();
     TeamRepository    = new TeamRepository(_dbContext);
     ChannelRepository = new ChannelRepository(_dbContext);
     UserRepository    = new UserRepository(_dbContext);
     MessageRepository = new MessageRepository(_dbContext);
 }
예제 #14
0
        /// <inheritdoc />
        protected override async Task InternalExecute(Channel userChannel, StasisStartEventArgs args)
        {
            var routeData = args.RouteData;

            if (!routeData.FromCallId.HasValue)
            {
                Logger.Warning($"Id вызова пользователя не задан. ChannelId: {userChannel.Id}");
                return;
            }

            var userExtension        = routeData.FromExtension;
            var destinationExtension = routeData.ToExtension;
            var destinationChannelId = AriClient.CreateChannelId(ChannelRoleType.ExternalChannel, destinationExtension);

            var bridge = await AriClient.CreateBridge();

            await AriClient.AddChannelToBridge(bridge.Id, userChannel.Id);

            var playBackId = await AriClient.PlayBeeps(userChannel.Id);

            var destinationCallArgs = new StasisStartEventArgs
            {
                BridgeId   = bridge.Id,
                EventType  = StasisStartEventType.CallToDestination,
                RouteData  = routeData,
                PlaybackId = playBackId
            };

            var encodedArgs     = JsonSerializer.EncodeData(destinationCallArgs);
            var originateResult = await AriClient.Originate(encodedArgs, "Служба 112", destinationExtension, destinationChannelId);

            if (!originateResult)
            {
                throw new Exception("Ошибка создания канала для участника разговора, которому звонит пользователь.");
            }

            var userChannelEntity = new DAL.Entities.Channel
            {
                ChannelId = userChannel.Id,
                Extension = userExtension,
                CallId    = routeData.FromCallId.Value,
                BridgeId  = bridge.Id,
                Role      = ChannelRoleType.Conference,
                LineId    = routeData.LineId
            };
            await ChannelRepository.AddChannel(userChannelEntity);

            var destinationChannelEntity = new DAL.Entities.Channel
            {
                ChannelId = destinationChannelId,
                Extension = destinationExtension,
                CallId    = routeData.ToCallId,
                BridgeId  = bridge.Id,
                Role      = ChannelRoleType.RingingFromUser,
                LineId    = routeData.LineId
            };
            await ChannelRepository.AddChannel(destinationChannelEntity);
        }
예제 #15
0
        public ActionResult FilterContactHandoverCollaborator()
        {
            // Check account user form
            var status = StoreData.CheckAccountUseHandover(EmployeeType.Collaborator);

            ViewBag.Channels      = ChannelRepository.GetAll();
            ViewBag.StatusMessage = status;
            return(View(new ContactCreateModel()));
        }
        private async Task HangUpAllChannelsInBridge(string bridgeId)
        {
            var allChannels = await ChannelRepository.GetByBridgeId(bridgeId);

            foreach (var channel in allChannels)
            {
                await AriClient.HangupChannel(channel.ChannelId);
            }
        }
예제 #17
0
        public ActionResult GoFilterMOL0()
        {
            // ChannelMOs
            var channels = ChannelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.MO);

            ViewBag.ChannelMOs = channels;

            return(View());
        }
예제 #18
0
        public List <ChannelInfo> FilterCountForHandover(string typeIds, string levelIds, string importIds, string statusIds, string containerIds, int employeeTypeId, int statusMapId, int statusCareId)
        {
            var type     = (EmployeeType)employeeTypeId;
            var branchId = UserContext.GetDefaultBranch();

            var list = ChannelRepository.FilterCountForHandover(branchId, typeIds, levelIds, importIds, statusIds, containerIds, type, statusMapId, statusCareId) ?? new List <ChannelInfo>();

            return(list.Count > 0 ? list.OrderBy(c => c.Name).ToList() : list);
        }
예제 #19
0
        static void Main(string[] args)
        {
            try
            {
                var repo = new ChannelRepository();

                Console.WriteLine("Obtendo feeds..");
                Console.WriteLine(new String('-', separatorCount));

                var result = repo.GetChannels();

                Console.WriteLine("Encontrou... : " + result.Count);
                Console.WriteLine(new String('-', separatorCount));


                result.ForEach(item => { Console.WriteLine($"Titulo: {item.Title}"); });

                Console.WriteLine(new String('-', separatorCount));

                result.ForEach(x =>
                {
                    Console.WriteLine($"{x.GetCountOfWords().ToString("000000")} Palavras para | {x.Title}");
                });

                var resultTopWords = repo.GetTopWordByTopic(result);

                Console.WriteLine(new String('-', separatorCount));
                Console.WriteLine("Top 10 palavras por tópico");
                Console.WriteLine(new String('-', separatorCount));

                foreach (var item in resultTopWords)
                {
                    Console.WriteLine($"Tópico: { item.Key}");
                    Console.Write('\n');

                    foreach (var dicTopWords in item.Value)
                    {
                        Console.WriteLine(new String(' ', 3) + dicTopWords.Value.ToString("00") + " - " + dicTopWords.Key.ToUpper());
                    }

                    Console.WriteLine(new String('-', separatorCount));
                }

                Console.ReadLine();
            }
            catch (TimeoutException ex)
            {
                Console.Write("Verifique sua conexao com a internet.\n\n" + ex.Message);
            }

            catch (Exception ex)
            {
                Console.Write("Erro ao tentar carregar os feeds: " + ex.Message);
            }
        }
예제 #20
0
        public IActionResult GetChannels()
        {
            List <Channel> channels = new ChannelRepository(context).GetChannels();

            if (channels == null)
            {
                return(BadRequest());
            }

            return(Ok(channels));
        }
예제 #21
0
        public List <ChannelInfo> FilterCountForHandoverMOL(string typeIds, string levelIds, string importIds, string statusIds, string containerIds, int employeeTypeId, int statusMapId, int statusCareId, string fromRegisterDate, string toRegisterDate)
        {
            var type            = (EmployeeType)employeeTypeId;
            var branchId        = UserContext.GetDefaultBranch();
            var fromRegisterDay = fromRegisterDate.ToDateTime("ddMMyyyy");
            var toRegisterDay   = toRegisterDate.ToDateTime("ddMMyyyy");

            var list = ChannelRepository.FilterCountForHandoverMOL(branchId, typeIds, levelIds, importIds, statusIds, containerIds, type, statusMapId, statusCareId, fromRegisterDay, toRegisterDay) ?? new List <ChannelInfo>();

            return(list.Count > 0 ? list.OrderBy(c => c.Name).ToList() : list);
        }
예제 #22
0
        public JsonResult GetForFilterTeam(int branchId, int collectorId, int channelId, int importId, int levelId, int sourceTypeId, int schoolId, int statusId, int page, int rows)
        {
            var list     = new MyContactListModel();
            var lstModel = new List <ContactModel>();
            int totalRecords;
            var data = ContactRepository.GetForFilterTeam(branchId, collectorId, channelId, importId, levelId, sourceTypeId, schoolId, statusId, page, rows, out totalRecords);

            foreach (var info in data)
            {
                var objModel = ObjectHelper.Transform <ContactModel, ContactInfo>(info);
                objModel.StatusName = ObjectExtensions.GetEnumDescription((StatusType)info.StatusId);
                var contactLevel = ContactLevelInfoRepository.GetInfo(info.Id);
                if (contactLevel != null)
                {
                    objModel.Notes = contactLevel.EducationSchoolName;
                }
                var collector = CollectorRepository.GetInfo(info.CollectorId);
                var channel   = ChannelRepository.GetInfo(info.ChannelId);
                var phones    = PhoneRepository.GetByContact(info.Id);
                foreach (var phone in phones)
                {
                    if (phone.IsPrimary == 1)
                    {
                        objModel.Mobile = phone.PhoneNumber;
                    }
                    else if (phone.PhoneType == PhoneType.HomePhone.ToString())
                    {
                        objModel.Tel = phone.PhoneNumber;
                    }
                    else
                    {
                        objModel.Mobile2 = phone.PhoneNumber;
                    }
                }
                if (collector != null)
                {
                    objModel.CollectorName = collector.Name;
                }
                if (channel != null)
                {
                    objModel.ChannelName = channel.Name;
                }

                lstModel.Add(objModel);
            }
            list.UserData = totalRecords;
            list.Rows     = lstModel;
            list.Page     = page;
            list.Total    = (totalRecords / rows) + 1;
            list.Records  = rows;
            return(new JsonResult {
                Data = list, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #23
0
        public int FilterContactCountForDistributor(int sourceTypeId, int typeCc, string statusMapIds, string from, string to, string channelIds, string schoolIds)
        {
            schoolIds  = schoolIds.Trim(',');
            channelIds = channelIds.Trim(',');
            var       branchId = UserContext.GetDefaultBranch();
            const int statusId = ((int)StatusType.New);
            var       fromDate = from.ToDateTime() ?? DateTime.Now.Date;
            var       toDate   = to.ToDateTime() ?? DateTime.Now.Date; toDate = toDate.AddDays(1).AddSeconds(-1);

            return(ChannelRepository.FilterContactCountForDistributor(branchId, sourceTypeId, statusId, fromDate, toDate, typeCc, statusMapIds, channelIds, schoolIds));
        }
        // GET: Items
        public ActionResult Index(int channelId)
        {
            var channel = new ChannelRepository(db).Find(channelId);

            ViewBag.ChannelID        = channelId;
            ViewBag.FeedDefinitionID = channel.FeedDefinitionID;

            var items = repo.GetByChannel(channelId);


            return(View(items.ToViewModels(catRepo)));
        }
예제 #25
0
 public UnitOfWork(LiveBotDBContext context)
 {
     _context               = context ?? throw new ArgumentNullException(nameof(context));
     GuildRepository        = new GuildRepository(context);
     ChannelRepository      = new ChannelRepository(context);
     RoleRepository         = new RoleRepository(context);
     SubscriptionRepository = new SubscriptionRepository(context);
     UserRepository         = new UserRepository(context);
     NotificationRepository = new NotificationRepository(context);
     GameRepository         = new GameRepository(context);
     AuthRepository         = new AuthRepository(context);
 }
        private async Task DeleteChannel(DAL.Entities.Channel channel)
        {
            if (channel.Role == ChannelRoleType.Assistant || channel.Role == ChannelRoleType.PartialAssistant || channel.Role == ChannelRoleType.SpeakSnoopChannel)
            {
                await ChannelRepository.DeleteChannel(channel.ChannelId);
                await HangUpAllChannelsInBridge(channel.BridgeId);

                return;
            }

            await ChannelRepository.DeleteChannel(channel.ChannelId);
        }
예제 #27
0
        public List <ChannelInfo> FilterCountForDistributor(int sourceTypeId, int typeCc, string statusMapIds, string from, string to)
        {
            var       branchId = UserContext.GetDefaultBranch();
            const int statusId = ((int)StatusType.New);
            var       fromDate = from.ToDateTime() ?? DateTime.Now.Date;
            var       toDate   = to.ToDateTime() ?? DateTime.Now.Date; toDate = toDate.AddDays(1).AddSeconds(-1);

            var list = ChannelRepository.FilterCountForDistributor(branchId, sourceTypeId, statusId, fromDate, toDate, typeCc, statusMapIds)
                       ?? new List <ChannelInfo>();

            return(list.Count > 0 ? list.OrderBy(c => c.Amount).ToList() : list);
        }
        public OctopusAsyncRepository(IOctopusAsyncClient client)
        {
            this.Client = client;

            Accounts                 = new AccountRepository(client);
            ActionTemplates          = new ActionTemplateRepository(client);
            Artifacts                = new ArtifactRepository(client);
            Backups                  = new BackupRepository(client);
            BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
            CertificateConfiguration = new CertificateConfigurationRepository(client);
            Certificates             = new CertificateRepository(client);
            Channels                 = new ChannelRepository(client);
            CommunityActionTemplates = new CommunityActionTemplateRepository(client);
            Configuration            = new ConfigurationRepository(client);
            DashboardConfigurations  = new DashboardConfigurationRepository(client);
            Dashboards               = new DashboardRepository(client);
            Defects                  = new DefectsRepository(client);
            DeploymentProcesses      = new DeploymentProcessRepository(client);
            Deployments              = new DeploymentRepository(client);
            Environments             = new EnvironmentRepository(client);
            Events = new EventRepository(client);
            FeaturesConfiguration = new FeaturesConfigurationRepository(client);
            Feeds                    = new FeedRepository(client);
            Interruptions            = new InterruptionRepository(client);
            LibraryVariableSets      = new LibraryVariableSetRepository(client);
            Lifecycles               = new LifecyclesRepository(client);
            MachinePolicies          = new MachinePolicyRepository(client);
            MachineRoles             = new MachineRoleRepository(client);
            Machines                 = new MachineRepository(client);
            Migrations               = new MigrationRepository(client);
            OctopusServerNodes       = new OctopusServerNodeRepository(client);
            PerformanceConfiguration = new PerformanceConfigurationRepository(client);
            ProjectGroups            = new ProjectGroupRepository(client);
            Projects                 = new ProjectRepository(client);
            ProjectTriggers          = new ProjectTriggerRepository(client);
            Proxies                  = new ProxyRepository(client);
            Releases                 = new ReleaseRepository(client);
            RetentionPolicies        = new RetentionPolicyRepository(client);
            Schedulers               = new SchedulerRepository(client);
            ServerStatus             = new ServerStatusRepository(client);
            Subscriptions            = new SubscriptionRepository(client);
            TagSets                  = new TagSetRepository(client);
            Tasks                    = new TaskRepository(client);
            Teams                    = new TeamsRepository(client);
            Tenants                  = new TenantRepository(client);
            TenantVariables          = new TenantVariablesRepository(client);
            UserRoles                = new UserRolesRepository(client);
            Users                    = new UserRepository(client);
            VariableSets             = new VariableSetRepository(client);
            Workers                  = new WorkerRepository(client);
            WorkerPools              = new WorkerPoolRepository(client);
        }
예제 #29
0
        //
        // GET: /Admin/ImportExcel/

        public ActionResult Index()
        {
            ViewBag.DefaultBranchId = UserContext.GetDefaultBranch();
            ViewBag.Collectors      = CollectorRepository.GetAll();
            ViewBag.Channels        = ChannelRepository.GetAll();
            ViewBag.SourceTypes     = SourceTypeRepository.GetAll();
            var levels = LevelRepository.GetAll();
            var L1n2   = levels.Where(x => x.LevelId < 3).ToList();

            ViewBag.Levels   = L1n2;
            ViewBag.Branches = BranchRepository.GetAll();
            return(View());
        }
예제 #30
0
        public ActionResult PrintForCollaborators()
        {
            var channels            = ChannelRepository.GetAll();
            var lstChannelWithCount = new List <ChannelWithContactCountModel>();

            foreach (var channel in channels)
            {
                var obj = ObjectHelper.Transform <ChannelWithContactCountModel, ChannelInfo>(channel);
                lstChannelWithCount.Add(obj);
            }
            ViewBag.Channels = lstChannelWithCount;
            return(View());
        }
예제 #31
0
 public OctopusRepository(IOctopusClient client)
 {
     this.Client = client;
     Feeds = new FeedRepository(client);
     Backups = new BackupRepository(client);
     Machines = new MachineRepository(client);
     MachineRoles = new MachineRoleRepository(client);
     MachinePolicies = new MachinePolicyRepository(client);
     Subscriptions = new SubscriptionRepository(client);
     Environments = new EnvironmentRepository(client);
     Events = new EventRepository(client);
     FeaturesConfiguration = new FeaturesConfigurationRepository(client);
     ProjectGroups = new ProjectGroupRepository(client);
     Projects = new ProjectRepository(client);
     Proxies = new ProxyRepository(client);
     Tasks = new TaskRepository(client);
     Users = new UserRepository(client);
     VariableSets = new VariableSetRepository(client);
     LibraryVariableSets = new LibraryVariableSetRepository(client);
     DeploymentProcesses = new DeploymentProcessRepository(client);
     Releases = new ReleaseRepository(client);
     Deployments = new DeploymentRepository(client);
     Certificates = new CertificateRepository(client);
     Dashboards = new DashboardRepository(client);
     DashboardConfigurations = new DashboardConfigurationRepository(client);
     Artifacts = new ArtifactRepository(client);
     Interruptions = new InterruptionRepository(client);
     ServerStatus = new ServerStatusRepository(client);
     UserRoles = new UserRolesRepository(client);
     Teams = new TeamsRepository(client);
     RetentionPolicies = new RetentionPolicyRepository(client);
     Accounts = new AccountRepository(client);
     Defects = new DefectsRepository(client);
     Lifecycles = new LifecyclesRepository(client);
     OctopusServerNodes = new OctopusServerNodeRepository(client);
     Channels = new ChannelRepository(client);
     ProjectTriggers = new ProjectTriggerRepository(client);
     Schedulers = new SchedulerRepository(client);
     Tenants = new TenantRepository(client);
     TagSets = new TagSetRepository(client);
     BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
     ActionTemplates = new ActionTemplateRepository(client);
     CommunityActionTemplates = new CommunityActionTemplateRepository(client);
 }
예제 #32
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        btnImport.Enabled = false;
        fuImport.Enabled = false;
        btnImport.Text = "Processing...";
        if (!fuImport.HasFile)
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Chọn file để nhập');", true);
        else
        {
            string ext = fuImport.FileName.Substring(fuImport.FileName.LastIndexOf('.') + 1).ToLower();
            if (!ext.Equals("xls") && !ext.Equals("xlsx"))
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Định dạng file nhập ko đúng');", true);
            else
            {
                string newFileName = Guid.NewGuid().ToString("N") + "." + ext;
                string pathToFile = Server.MapPath("~\\Import") + "\\" + newFileName;
                fuImport.SaveAs(pathToFile);
                try
                {
                    ObjLogin adm = (ObjLogin)Session["objLogin"];

                    int smsquota = int.Parse(ConfigurationManager.AppSettings["SMSQuota"]);
                    double expiredDateConfig = Convert.ToDouble(ConfigurationManager.AppSettings["ExpiredDate"]);
                    DateTime expiredDate = Convert.ToDateTime(DateTime.Now.AddDays(expiredDateConfig));

                    var GRepo = new GroupsRepository();
                    var RegionRepo = new RegionsRepository();
                    var AreaRepo = new AreasRepository();
                    var LocalRepo = new LocalsRepository();
                    var ChRepo = new ChannelRepository();
                    var SaleRepo = new SalesmanRepository();
                    var CLogRepo = new CustomersLogRepository();
                    var CRepo = new CustomersRepository();
                    var CTRepo = new CustomerTypeRepository();
                    var DisRepo = new DistrictsRepository();
                    var proviceRepo = new ProvincesRepository();
                    var sectionRepo = new SectionRepository();

                    SpreadsheetInfo.SetLicense("E24D-D739-F65A-4E00");
                    ExcelFile ef = new ExcelFile();
                    ef.LoadXls(pathToFile);
                    ExcelWorksheet ws = ef.Worksheets[0];

                    for (int i = 2; i < ws.Rows.Count; i++)
                    {
                        try
                        {
                            vwMasterList vmMasterItem = new vwMasterList(ws.Rows[i].Cells[4].Value.ToString(),
                                                                ws.Rows[i].Cells[5].Value.ToString(),
                                                                ws.Rows[i].Cells[6].Value.ToString(),
                                                                ws.Rows[i].Cells[7].Value.ToString(),
                                                                ws.Rows[i].Cells[8].Value.ToString(),
                                                                ws.Rows[i].Cells[9].Value.ToString(),
                                                                ws.Rows[i].Cells[10].Value.ToString(),
                                                                ws.Rows[i].Cells[11].Value.ToString(),
                                                                ws.Rows[i].Cells[12].Value.ToString(),
                                                                ws.Rows[i].Cells[13].Value.ToString(),
                                                                ws.Rows[i].Cells[14].Value.ToString(),
                                                                ws.Rows[i].Cells[15].Value.ToString(),
                                                                ws.Rows[i].Cells[17].Value.ToString(),
                                                                ws.Rows[i].Cells[18].Value.ToString(),
                                                                ws.Rows[i].Cells[19].Value.ToString(),
                                                                ws.Rows[i].Cells[20].Value.ToString(),
                                                                ws.Rows[i].Cells[22].Value.ToString(),
                                                                ws.Rows[i].Cells[23].Value.ToString(),
                                                                ws.Rows[i].Cells[24].Value.ToString());

                            // Add Group - Region - Area - Local
                            var groupId = GRepo.Import("", vmMasterItem.Group, "");
                            var regionId = RegionRepo.Import("", vmMasterItem.Region, "", groupId);
                            var areaId = AreaRepo.Import("", vmMasterItem.Area, "", regionId);
                            var localId = LocalRepo.Import("", vmMasterItem.Local, "", areaId);

                            // Add section
                            var sectionId = sectionRepo.Import(vmMasterItem.Area);

                            // Add Province
                            var provinceId = proviceRepo.Import(vmMasterItem.Local, sectionId);

                            // Add District
                            var districtId = DisRepo.Import(vmMasterItem.Local, provinceId);

                            // Add Channel
                            ChRepo.Insert("", vmMasterItem.Channel1, 0);
                            ChRepo.Insert("", vmMasterItem.Channel2, ChRepo.GetChannelIdByName(vmMasterItem.Channel1));
                            ChRepo.Insert("", vmMasterItem.Channel3, ChRepo.GetChannelIdByName(vmMasterItem.Channel2));

                            // Add Customer Type
                            CTRepo.Add("", vmMasterItem.Channel3);

                            // Add Salesmen
                            var tromId = SaleRepo.ImportSalesmen("", vmMasterItem.TROM, "", (int)SalesmenRole.TROM, smsquota, expiredDate, -1);
                            var tpsId = SaleRepo.ImportSalesmen("", vmMasterItem.TPS, "", (int)SalesmenRole.TPS, smsquota, expiredDate, tromId);
                            var tprId = SaleRepo.ImportSalesmen("", vmMasterItem.TPR, "", (int)SalesmenRole.TPR, smsquota, expiredDate, tpsId);

                            var eromId = SaleRepo.ImportSalesmen("", vmMasterItem.EROM, "", (int)SalesmenRole.EROM, smsquota, expiredDate, -1);
                            var pss1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS1, "", (int)SalesmenRole.PSS1, smsquota, expiredDate, eromId);
                            var psr1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR1, "", (int)SalesmenRole.PSR1, smsquota, expiredDate, pss1Id);

                            var erom2Id = SaleRepo.ImportSalesmen("", vmMasterItem.EROM2, "", (int)SalesmenRole.EROM2, smsquota, expiredDate, -1);
                            var pss2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS2, "", (int)SalesmenRole.PSS2, smsquota, expiredDate, erom2Id);
                            var psr2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR2, "", (int)SalesmenRole.PSR2, smsquota, expiredDate, pss2Id);

                            // Add Salesgroup - salesregion - salesarea - saleslocal
                            ImportSalesGroup(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, GRepo, groupId);
                            ImportSalesRegion(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, RegionRepo, regionId);
                            ImportSalesArea(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, AreaRepo, areaId);
                            ImportSalesLocal(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, LocalRepo, localId);

                            // Add Customer - Customer Log
                            int CustomerId = CRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "",
                                CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3),
                                ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now,
                                true, false);
                            CLogRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "",
                                CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3),
                                ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now,
                                true, CustomerId, false, 0, adm.Id, string.Empty);

                            lstCustomer.Add(vmMasterItem);
                        }
                        catch (Exception ex)
                        {
                            // write log here => TBD
                        }
                    }

                    CustomerList.DataSource = lstCustomer;
                    CustomerList.DataBind();
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('" + ex.Message + "');", true);
                }
                finally
                {

                }

            }
        }
        btnImport.Enabled = true;
        fuImport.Enabled = true;
        btnImport.Text = "Import";
    }