Exemplo n.º 1
0
        public IEnumerable <MessageUC> GetMessages(ChatModel chatModel)
        {
            List <MessageUC>         messageUCs  = new List <MessageUC>();
            IService                 service     = new WCFService();
            IChatMap                 chatMap     = new Map();
            IEnumerable <MessageDTO> messageDTOs = service.GetMessages(chatMap.ChatModelToChatDTO(chatModel));

            if (messageDTOs != null)
            {
                foreach (MessageDTO mess in messageDTOs)
                {
                    MessageUC messageUC = new MessageUC();
                    MessageVM messageVM = new MessageVM();
                    messageVM.Message.Id     = mess.Id;
                    messageVM.Message.Text   = mess.Text;
                    messageVM.Message.Time   = mess.Time;
                    messageVM.Message.Author = mess.Author;
                    messageVM.Message.Img    = mess.Img;

                    messageUC.DataContext = messageVM;
                    messageUCs.Add(messageUC);
                }
            }

            return(messageUCs);
        }
Exemplo n.º 2
0
        public bool GetLogin(LoginModel model)
        {
            ISignMap signMap = new Map();


            IService service = new WCFService();
            //Socket service = new Socket();


            AccountDTO accountDTO = new AccountDTO();

            string    host      = System.Net.Dns.GetHostName();
            DeviceDTO deviceDTO = new DeviceDTO
            {
                DeviceIp   = Dns.GetHostEntry(host).AddressList[0].ToString(),
                DeviceName = host,
                DeviceTime = DateTime.Now.ToLongTimeString()
            };

            accountDTO = service.LoginService(signMap.LoginModelToLoginDTO(model), deviceDTO);
            if (accountDTO != null)
            {
                MyUser.SetNewUser(signMap.AccountDTOToUserModel(accountDTO));
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public IEnumerable <ChatLookUC> GetSoloChatUC(string token)
        {
            List <ChatLookUC>     soloChatUCs = new List <ChatLookUC>();
            IService              service     = new WCFService();
            IEnumerable <ChatDTO> chatDTOs    = service.GetChats(token);

            if (chatDTOs != null)
            {
                foreach (ChatDTO chat in chatDTOs)
                {
                    ChatLookUC soloChatUC = new ChatLookUC();
                    SoloChatVM soloChatVM = new SoloChatVM();

                    soloChatVM.Chat.Id     = chat.Id;
                    soloChatVM.Chat.Img    = chat.Img;
                    soloChatVM.Chat.Name   = chat.Name;
                    soloChatVM.Chat.Status = chat.Status;

                    soloChatUC.DataContext = soloChatVM;



                    soloChatUCs.Add(soloChatUC);
                }
            }

            return(soloChatUCs);
        }
Exemplo n.º 4
0
        public IEnumerable <ChatLookUC> GetGroupChatUC(string token)
        {
            List <ChatLookUC> groupChatUCs = new List <ChatLookUC>();

            IService service = new WCFService();
            IEnumerable <GroupChatDTO> groupChats = service.GetGroupChat(token);

            if (groupChats != null)
            {
                foreach (GroupChatDTO chat in groupChats)
                {
                    ChatLookUC  groupChatUC = new ChatLookUC();
                    GroupChatVM groupChatVM = new GroupChatVM();
                    groupChatVM.Chat.Id          = chat.Id;
                    groupChatVM.Chat.Img         = chat.Img;
                    groupChatVM.Chat.Name        = chat.Name;
                    groupChatVM.Chat.Status      = chat.Status + " users";
                    groupChatVM.Chat.ChatAdminId = chat.ChatAdminId;
                    groupChatUC.DataContext      = groupChatVM;

                    groupChatUCs.Add(groupChatUC);
                }
            }

            return(groupChatUCs);
        }
Exemplo n.º 5
0
        public ChatModel GetOrCreateChat(AccountModel user, string token)
        {
            IUserMap userMap = new Map();
            IChatMap chatMap = new Map();
            IService service = new WCFService();

            return(chatMap.ChatDTOToChatModel(service.GetOrCreateChat(userMap.AccountModelToAccountDTO(user), token)));
        }
Exemplo n.º 6
0
 public void FileUpload()
 {
     System.IO.FileInfo fileInfo = new System.IO.FileInfo("C:\\DEV\\test.pdf");
     using (System.IO.FileStream stream = new System.IO.FileStream("C:\\DEV\\test.pdf", System.IO.FileMode.Open, System.IO.FileAccess.Read))
     {
         WCFService <ILocalService> .getChannelFactory().UploadFile(fileInfo.Name, stream);
     }
 }
Exemplo n.º 7
0
 public void Start()
 {
     foreach (Thread thread in list_thread)
     {
         thread.Start();
     }
     WCFService wcf = new WCFService(conf);
 }
Exemplo n.º 8
0
        private static void Main(string[] args)
        {
            using (WCFService service = new WCFService("AppService", typeof(UserAccountService)))
            {
                service.Open();

                Console.ReadLine();
            }
        }
Exemplo n.º 9
0
 public ActionResult Login(WCFService.User user)
 {
     var login = Database.Instance.UserProxy.FindUserByCredentials(user.Username, user.Password);
     if (login != null)
     {
         Session["uid"] = login.Id;
     }
     return View();
 }
Exemplo n.º 10
0
        public void SendMessage(ChatModel chatModel, string mess)
        {
            IService service = new WCFService();
            IChatMap chatMap = new Map();

            if (!service.SendMessage(chatMap.ChatModelToChatDTO(chatModel), MyUser.User.UserToken, mess))
            {
                MessageBox.Show("Error");
            }
        }
Exemplo n.º 11
0
        private void Button3_Click(object sender, EventArgs e)
        {
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("EQP_ID", "17");
            var result = WCFService <ICommonService> .getChannelFactory("Common").SelectDeptList(parameters);

            parameters.Add("ID", "aaa");
            var result2 = WCFService <IAutomationService> .getChannelFactory("Automation").SelectSiteList(parameters);
        }
Exemplo n.º 12
0
        private static void Main(string[] args)
        {
            using (WCFService service = new WCFService("ReplicationService", typeof(ReplicationService)))
            {
                service.Open();

                Console.ReadLine();
            }
            Console.ReadLine();
        }
        private Service CreateDefaultService()
        {
            Service    rootElement = new Service(Store);
            WCFService wcfService  = new WCFService();

            wcfService.ModelElement          = rootElement;
            rootElement.ObjectExtender       = wcfService;
            rootElement.Name                 = ServiceName;
            rootElement.ServiceContractModel = new ServiceContractModel(Store);
            rootElement.ServiceContractModel.ProjectMappingTable = "WCF";
            return(rootElement);
        }
Exemplo n.º 14
0
 static void Main(string[] args){
     //instantiate the event receiver
     Consumer c = new Consumer();
     // instantiate the event source
     WCFService svc = new WCFService();
     svc.WCFEvent += new SomeEventHandler(c.ProcessTheRaisedEvent);
     using(ServiceHost host = new ServiceHost(svc))
     {
         host.Open();
         Console.Readline();
     }
 }
Exemplo n.º 15
0
        public IEnumerable <AccountModel> GetUserViewUCs(string teg)
        {
            IService                 service       = new WCFService();
            List <AccountModel>      accountModels = new List <AccountModel>();
            IUserMap                 userMap       = new Map();
            IEnumerable <AccountDTO> accountDTOs   = service.GetAccountsByTeg(teg, MyUser.User.UserToken);

            foreach (AccountDTO accountDTO in accountDTOs)
            {
                accountModels.Add(userMap.AccountDTOToAccountModel(accountDTO));
            }
            return(accountModels);
        }
Exemplo n.º 16
0
        public ActionResult Visa(WCFService.Visa visa)
        {
            if (Session["uid"] != null)
            {
                // Ran out of time to implment the address form
                var data = Database.Instance.OrderProxy.InsertOrderFromUser((int)Session["uid"], new WCFService.Address(), visa);
                if (data)
                    ViewBag.Information = "Order purchased";
                else
                    ViewBag.Warning = "Could not purchase order.";

            }
            return View();
        }
Exemplo n.º 17
0
        public ActionResult Register(WCFService.User user)
        {
            ViewBag.Title = "Register";
            ViewBag.Message = "Register an account.";

            var register = Database.Instance.UserProxy.Insert(user);

            if (register == true)
                ViewBag.Information = "User registered.";
            else
                ViewBag.Warning = "Cannot register user";

            return View();
        }
Exemplo n.º 18
0
        public bool ChangeAccount(ChangeModel model)
        {
            IService service = new WCFService();
            IUserMap userMap = new Map();

            if (service.ChangeAccount(userMap.ChangeModelToChangeDTO(model)))
            {
                MyUser.User.UserEmail    = model.Email;
                MyUser.User.UserImg      = model.Img;
                MyUser.User.UserPassword = model.NewPassword;
                return(true);
            }

            return(false);
        }
		public void NullServiceContractGeneratesServiceContract()
		{
			ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

			Service rootElement = CreateDefaultService();
			rootElement.Namespace = ServiceNamespace;
			WCFService extender = new WCFService();
			extender.ModelElement = rootElement;
			rootElement.ObjectExtender = extender;
			rootElement.ServiceContract = null;

			string content = RunTemplate(rootElement);

			Type generatedType = CompileAndGetType(content);
			TypeAsserter.AssertInterface(ServiceContractInterfaceName, generatedType, 0);
		}
Exemplo n.º 20
0
 private void GetLoginContext_Completed(object sender, WCFService.GetLoginContextCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         // success
         Program.LoginContext = e.Result;
         client = null;
         // start getting computer info async
         loadinglabel.Text = "examining computer ...";
         var thread = new System.Threading.Thread(GetComputerInfo);
         thread.Start(syncContext);
     }
     else
     {
         SetError(e.Error.Message);
     }
 }
		public void TestHeaderGeneration()
		{
			ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");
            
			Service rootElement = CreateDefaultService();
			rootElement.Namespace = ServiceNamespace;
			WCFService extender = new WCFService();
			extender.ModelElement = rootElement;
			rootElement.ObjectExtender = extender;
			string content = RunTemplate(rootElement);

			Type generatedType = CompileAndGetType(content);
			ServiceBehaviorAttribute serviceBehavior = TypeAsserter.AssertAttribute<ServiceBehaviorAttribute>(generatedType);
			Assert.AreEqual<string>(ServiceName, serviceBehavior.Name);
			Assert.AreEqual<string>(ServiceNamespace, serviceBehavior.Namespace);
			Assert.AreEqual<InstanceContextMode>(InstanceContextMode.PerSession, serviceBehavior.InstanceContextMode);
			Assert.AreEqual<ConcurrencyMode>(ConcurrencyMode.Single, serviceBehavior.ConcurrencyMode);
		}
        public void NullServiceContractGeneratesServiceContract()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

            Service rootElement = CreateDefaultService();

            rootElement.Namespace = ServiceNamespace;
            WCFService extender = new WCFService();

            extender.ModelElement       = rootElement;
            rootElement.ObjectExtender  = extender;
            rootElement.ServiceContract = null;

            string content = RunTemplate(rootElement);

            Type generatedType = CompileAndGetType(content);

            TypeAsserter.AssertInterface(ServiceContractInterfaceName, generatedType, 0);
        }
Exemplo n.º 23
0
        public WCFService GetGame(string clientVersion, string login)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login))
                {
                    return(null);
                }

#if !DEBUG
                //проверка версии клиента
                if (!string.IsNullOrEmpty(_UpdaterService.ClientVersion) && clientVersion != _UpdaterService.ClientVersion)
                {
                    return(null);
                }
#endif

                _GamePortalService.AddOnlineUser(login);

                WCFService result = new WCFService()
                {
                    IsDisableNewGame = IsDisableNewGame
                };
                using (Agot2p6Entities dbContext = new Agot2p6Entities())
                {
#if DEBUG
                    IEnumerable <Game> games = dbContext.Game.ToList().Where(p => GameHost.GameTypes.All(p1 => p.Id != p1.GameId));
#endif
#if !DEBUG
                    IQueryable <Game> games = dbContext.Game.Where(p => p.CreatorLogin != "System");
#endif
                    result.Games = games.ToList().Select(p => p.ToWCFGame()).ToList();
                }

                return(result);
            }
            catch (Exception exp)
            {
                GameException.NewGameException(null, "Не удалось подготовить список игр.", exp, false);
                return(null);
            }
        }
        public void TestHeaderGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

            Service rootElement = CreateDefaultService();

            rootElement.Namespace = ServiceNamespace;
            WCFService extender = new WCFService();

            extender.ModelElement      = rootElement;
            rootElement.ObjectExtender = extender;
            string content = RunTemplate(rootElement);

            Type generatedType = CompileAndGetType(content);
            ServiceBehaviorAttribute serviceBehavior = TypeAsserter.AssertAttribute <ServiceBehaviorAttribute>(generatedType);

            Assert.AreEqual <string>(ServiceName, serviceBehavior.Name);
            Assert.AreEqual <string>(ServiceNamespace, serviceBehavior.Namespace);
            Assert.AreEqual <InstanceContextMode>(InstanceContextMode.PerSession, serviceBehavior.InstanceContextMode);
            Assert.AreEqual <ConcurrencyMode>(ConcurrencyMode.Single, serviceBehavior.ConcurrencyMode);
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            var settings   = new SettingsStorage();
            var detections = new DetectionsHistory();
            var logs       = new LogsHistory();

            //logs.Add(new LogMessage("log1", Severity.Information));
            //logs.Add(new LogMessage("log2", Severity.Warning));
            //logs.Add(new LogMessage("log3", Severity.Error));


            var systemService = new SystemService(settings, detections, logs);
            var wcfService    = new WCFService(systemService);

            Console.WriteLine("started");

            while (true)
            {
                Thread.Sleep(5000);
            }
            //wcfService.Dispose();
        }
Exemplo n.º 26
0
        public ServerInstance(HELLION hellion)
        {
            WCFService.Init(true);


            m_managers = new List <HesManager>();

            m_instance = this;

            m_hellion = hellion;

            hellion.OnServerStarted += OnServerStarted;
            hellion.OnServerStopped += OnServerStopped;

            WCFService.CreateServiceHost(typeof(ServerService), typeof(IServerService), "Server", "");

            CreateManagers();

            WCFService.Start();

            //TODO: this is temp! will be controlled via the manager or
            StartServer();
        }
Exemplo n.º 27
0
        private static void Main(string[] args)
        {
            repService = WCFClient.GetInstance().GetConnection <IReplicationContract>("ReplicationService");

            Task.Run(() =>
            {
                Replicate();
            });

            using (WCFService service = new WCFService("AuthService", typeof(UserAuthService)))
            {
                service.Open();
                using (WCFService authservice = new WCFService("AppAuthService", typeof(AppAuthService)))
                {
                    authservice.Open();


                    Console.ReadLine();
                }
                Console.ReadLine();
            }
            Console.ReadLine();
        }
Exemplo n.º 28
0
        public IEnumerable <DeviceUC> GetDeviceUC()
        {
            List <DeviceUC>         deviceUCs = new List <DeviceUC>();
            IEnumerable <DeviceDTO> deviceDTOs;
            IService service = new WCFService();

            deviceDTOs = service.GetDevicesByToken(MyUser.User.UserToken);

            if (deviceDTOs != null)
            {
                int i = 1;
                foreach (DeviceDTO dev in deviceDTOs)
                {
                    DeviceUC deviceUC = new DeviceUC();
                    deviceUC._idTb.Text   = i++ + ".";
                    deviceUC._nameTb.Text = dev.DeviceName;
                    deviceUC._ipTb.Text   = dev.DeviceIp;
                    deviceUC._timeTb.Text = dev.DeviceTime;
                    deviceUCs.Add(deviceUC);
                }
            }

            return(deviceUCs);
        }
		private Service CreateDefaultService()
		{
			Service rootElement = new Service(Store);
			WCFService wcfService = new WCFService();
			wcfService.ModelElement = rootElement;
			rootElement.ObjectExtender = wcfService;
			rootElement.Name = ServiceName;
			rootElement.ServiceContractModel = new ServiceContractModel(Store);
			rootElement.ServiceContractModel.ProjectMappingTable = "WCF";
			return rootElement;
		}
Exemplo n.º 30
0
 void proxy_GetLogCompleted(object sender, WCFService.ServiceReference1.GetLogCompletedEventArgs e)
 {
     lstWCF.ItemsSource = e.Result;
 }
Exemplo n.º 31
0
 public void FileDownload()
 {
     Stream stream = WCFService <ILocalService> .getChannelFactory().DownloadFile("test", "pdf");
 }
Exemplo n.º 32
0
 public WCFClient(WCFService service)
 {
     _service = service;
 }
Exemplo n.º 33
0
 private void GetComputer_Completed(object sender, WCFService.GetComputerCompletedEventArgs e)
 {
     if (e.Result.Status == Statics.Result.Success)
     {
         if (e.Result.ResultAsComputer.Exists)
         {
             namestatuslabel.Text = "Computer already exists !";
             namestatusimage.Image = global::Cdw.App.Properties.Resources.error_shield_small;
             nextbutton.Enabled = false;
             Program.Computer.Name = "";
         }
         else
         {
             namestatuslabel.Text = "Computer name is available !";
             namestatusimage.Image = global::Cdw.App.Properties.Resources.good_shield_small;
             Program.Computer.Name = namebox.Text;
             nextbutton.Enabled = true;
         }
     }
     else
     {
         MessageBox.Show(string.Concat(e.Result.Errors.ToArray()), "Search error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         namestatusimage.Image = global::Cdw.App.Properties.Resources.error_shield_small;
         nextbutton.Enabled = false;
     }
 }
Exemplo n.º 34
0
 private void GetSoftware_Completed(object sender, WCFService.GetSoftwareCompletedEventArgs e)
 {
     softwarepanel.Visible = false;
     if (e.Error == null)
     {
         Program.Software = e.Result.ToList();
         BuildSoftwareList();
     }
     else
     {
         MessageBox.Show(e.Error.Message, "Error getting software", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 35
0
        public Initializer(EventHandler <EventArgs> configChangedHandler)
        {
            var configuration = SipServerConfigurationSection.GetSection();

            var adUsers = (configuration.IsActiveDirectoryEnabled == false) ? null : new AdUsers(configuration.ActiveDirectoryGroup);

            Func <Userz> CreateUserz = () =>
            {
                var result = new Userz(configuration.CustomUsersPath);

                result.Add(new CsvUsers(configuration.UsersCsvFilePathName));
                if (adUsers != null)
                {
                    result.Add(adUsers);
                }

                result.LoadCustomUsers();

                return(result);
            };


            var serversManager    = new ServersManager <Connection>(new ServersManagerConfig());
            var transportLayer    = new TransportLayer(serversManager, configuration.WebSocketResponseFrame);
            var authorization     = new SipAuthorizationManager();
            var transactionLayer  = new TransactionLayer(authorization);
            var userz             = CreateUserz();
            var locationService   = new LocationService();
            var mras              = new Mras.Mras1();
            var trunkManager      = new TrunkManager();
            var accounts          = new Accountx(configuration.AccountConfigFilePathName);
            var msPresTu          = new MsPresTU(accounts, userz, locationService);
            var wcfService        = new WCFService(configuration, msPresTu.EnhancedPresence, trunkManager, accounts, userz);
            var httpAuthorization = new HttpAuthorizationManager();
            var httpServer        = new HttpServer(httpAuthorization, configuration.AdminUri);
            //var httpServerAgentRegistrar = new Func<IHttpServerAgent, IHttpServer>((agent) => { return httpServer.Register(agent); });
            var restapi = new RestapiService(accounts, userz)
            {
                AdministratorPassword = configuration.AdministratorPassword,
            };
            var httpFileServer       = new HttpFileServer(configuration.WwwPath, string.Empty);
            var xcapServer           = new XcapServer();
            var configurationMonitor = new ConfigurationMonitor();
            var simpleModule         = new SimpleModule(EqualityComparer <string> .Default);
            var proxyServerTU        = new ProxyServerTU(locationService, trunkManager, accounts);

            GetResults = (
                out TransportLayer transportLayer1,
                out TransactionLayer transactionLayer1,
                out LocationService locationService1,
                out WCFService wcfService1,
                out ConfigurationMonitor configurationMonitor1,
                out TrunkManager trunkManager1,
                out SipAuthorizationManager authorization1,
                out Userz userz1,
                out AdUsers adUsers1,
                out Mras.Mras1 mras1,
                out HttpFileServer httpFileServer1,
                out Accountx accounts1,
                out RestapiService restapi1,
                out ProxyServerTU proxyServerTU1
                ) =>
            {
                transportLayer1       = transportLayer;
                transactionLayer1     = transactionLayer;
                locationService1      = locationService;
                wcfService1           = wcfService;
                configurationMonitor1 = configurationMonitor;
                trunkManager1         = trunkManager;
                authorization1        = authorization;
                userz1          = userz;
                adUsers1        = adUsers;
                mras1           = mras;
                httpFileServer1 = httpFileServer;
                accounts1       = accounts;
                restapi1        = restapi;
                proxyServerTU1  = proxyServerTU;
            };


            Action InitializeTracer = () =>
            {
                Tracer.Initialize(serversManager.Logger);
                Tracer.Configure(configuration.TracingPath, configuration.IsTracingEnabled);
            };


            Action InitializeConfigurationMonitor = () =>
            {
                configurationMonitor.Changed += configChangedHandler;
                configurationMonitor.StartMonitoring(configuration);
            };

            Action InitializeHttpModules = () =>
            {
                httpServer.SendAsync = transportLayer.SendAsyncHttp;
                transportLayer.IncomingHttpRequest = httpServer.ProcessIncomingRequest;

                httpServer.Register(restapi, 0, true);
                httpServer.Register(xcapServer, 0, true);
                httpServer.Register(new HttpFileServer(configuration.WwwAdminPath, configuration.AdminUri), 254, true);
                httpServer.Register(httpFileServer, 255, true);

                xcapServer.AddHandler(new ResourceListsHandler(accounts, userz));
                xcapServer.AddHandler(new PidfManipulationHandler(simpleModule));
            };

            Action InitializeWcfService = () =>
            {
                wcfService.Start();
            };


            Action InitializeProxyServerTU = () =>
            {
                proxyServerTU.IsOfficeSIPFiletransferEnabled = configuration.IsOfficeSIPFiletransferEnabled;
            };


            Action InitializeTransactionLayer = () =>
            {
                InitializeProxyServerTU();

                transportLayer.IncomingMessage += transactionLayer.IncomingMessage;
                transportLayer.SendErrorSip    += transactionLayer.TransportError;
                transactionLayer.SendAsync      = transportLayer.SendAsyncSip;
                transactionLayer.IsLocalAddress = transportLayer.IsLocalAddress;

                serversManager.EndConnection += (s, c) => { locationService.RemoveBindingsWhenConnectionEnd(c.Id); };
                transactionLayer.RegisterTransactionUser(new RegistrarTU(locationService, accounts));

                transactionLayer.RegisterTransactionUser(msPresTu);

                transactionLayer.RegisterTransactionUser(new SimpleTU(simpleModule));
                transactionLayer.RegisterTransactionUser(new OptionsTU());
                transactionLayer.RegisterTransactionUser(new MessageSummaryTU());

                transactionLayer.RegisterTransactionUser(new MrasTU(mras));

                transactionLayer.RegisterTransactionUser(new DirectorySearchTU(accounts, new ServiceSoap.ServiceSoap1(), userz));

                transactionLayer.RegisterTransactionUser(proxyServerTU);

                transactionLayer.RegisterTransactionUser(new TrunkTU(trunkManager));
                transactionLayer.RegisterTransactionUser(new ErrorTU());
            };


            Action InitializeAuthorization = () =>
            {
                authorization.IsEnabled = configuration.IsAuthorizationEnabled;

                if (configuration.IsActiveDirectoryEnabled)
                {
                    var kerberosAuth = new SipMicrosoftAuthentication(SipAuthSchemes.Kerberos, accounts, userz);
                    var ntlmAuth     = new SipMicrosoftAuthentication(SipAuthSchemes.Ntlm, accounts, userz);

                    authorization.RegisterAgent(kerberosAuth, SipAuthSchemes.Kerberos);
                    authorization.RegisterAgent(ntlmAuth, SipAuthSchemes.Ntlm);
                }

                var digestAuth = new SipDigestAuthentication(accounts, userz, configuration.IsAuthIntEnabled);
                authorization.RegisterAgent(digestAuth, SipAuthSchemes.Digest);



                httpAuthorization.IsEnabled = configuration.IsAuthorizationEnabled;
                httpAuthorization.RegisterAgent(new HttpDigestAuthentication(accounts, userz, false), HttpAuthSchemes.Digest);
            };


            Action InitializeServersManager = () =>
            {
                serversManager.FakeAddressAction = (ServerEndPoint localEndpoint) =>
                {
                    foreach (var portForwarding in configuration.PortForwardings)
                    {
                        if (localEndpoint.Equals(portForwarding.Protocol, portForwarding.LocalEndpoint))
                        {
                            return(portForwarding.ExternalEndpoint);
                        }
                    }

                    return(null);
                };

                Action <ServerProtocol, int> bind = (protocol, port) =>
                {
                    if (port > 0)
                    {
                        var error = serversManager.Bind(new ProtocolPort()
                        {
                            Protocol = protocol,
                            Port     = port,
                        });

                        if (error != SocketError.Success)
                        {
                            Tracer.WriteError("Can't open " + protocol + " port " + port + ".\r\n" + error.ToString());
                        }
                    }
                };

                if (configuration.UdpPort > 0)
                {
                    bind(ServerProtocol.Udp, configuration.UdpPort);
                }
                if (configuration.TcpPort > 0)
                {
                    bind(ServerProtocol.Tcp, configuration.TcpPort);
                }
                if (configuration.TcpPort2 > 0)
                {
                    bind(ServerProtocol.Tcp, configuration.TcpPort2);
                }
            };

            ConfigureMras(mras, configuration);
            InitializeConfigurationMonitor();
            InitializeTracer();
            InitializeTransactionLayer();
            InitializeAuthorization();
            InitializeWcfService();
            InitializeHttpModules();
            InitializeServersManager();
        }
 internal void OnQuit()
 {
     WCFService.Stop();
 }
Exemplo n.º 37
0
        public ActionResult User(WCFService.User user)
        {
            ViewBag.Title = "Edit user";
            ViewBag.Message = "Edit your account.";

            if (Session["uid"] != null)
            {
                int userId = (int)Session["uid"];
                var data = Database.Instance.UserProxy.FindUserById(userId);
                data.Username = user.Username;
                data.Email = user.Email;
                var update = Database.Instance.UserProxy.Edit(data);
                return View(user);
            }
            return View();
        }
Exemplo n.º 38
0
 private void GetUser_Completed(object sender, WCFService.GetUserCompletedEventArgs e)
 {
     ownersearchpanel.Visible = false;
     if (e.Error == null)
     {
         if (e.Result.Status == Statics.Result.Success)
         {
             ownerpanel.Visible = true;
             var user = (User)e.Result.ResultAsUser;
             lb_owner_displayname.Text = user.DisplayName;
             lb_owner_department.Text = user.Department;
             lb_owner_email.Text = user.Email;
             // the user may have filled in the description / department and backed up to change the owner.
             if ((descriptionbox.Text.Length == 0) && (departmentbox.Text.Length == 0))
             {
                 // fill in the suggested fields !
                 descriptionbox.Text = user.DisplayName;
                 departmentbox.Text = user.Department;
             }
             Program.Computer.Owner = user.Username;
             nextbutton.Enabled = true;
         }
         else
         {
             MessageBox.Show(string.Concat(e.Result.Errors.ToArray()), "Search error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             nextbutton.Enabled = false;
         }
     }
     else
     {
         MessageBox.Show(e.Error.Message, "Search error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         nextbutton.Enabled = false;
     }
 }