Example #1
0
        private TransportService CreateTransportService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TransportService(userId);

            return(service);
        }
Example #2
0
 /// <summary>
 /// Authorization
 /// </summary>
 /// <param name="login">Login (email)</param>
 /// <param name="password">Auth password</param>
 /// <returns></returns>
 public bool Login(string login, string password)
 {
     this.options.Login    = login;
     this.options.Password = password;
     transportService      = new TransportService(this.options.Login, this.options.Password, this.options.Url, this.options.Database, new Tools.JsonParser());
     return(transportService.Login());
 }
        public ActionResult TransportList(FormCollection form)
        {
            var    svTranport = new TransportService();
            String SQLWhere   = "IsDelete = 0 AND IsShow = 1";

            SelectList_PageSize();
            SetPager(form);
            if (!string.IsNullOrEmpty(form["SearchText"]))
            {
                SQLWhere += " AND BannerTitle LIKE N'%" + form["SearchText"].Trim() + "%'";
            }
            else
            {
                GetStatusUser();
                SetPager(form);
                var Transport = svTranport.SelectData <OuikumTransport>("*", "IsDelete = 0 AND IsShow = 1", "ListNo ASC", (int)ViewBag.PageIndex, (int)ViewBag.PageSize);
                ViewBag.Transport = Transport;
                ViewBag.TotalPage = svTranport.TotalPage;
                ViewBag.TotalRow  = svTranport.TotalRow;
            }
            var transport = svTranport.SelectData <OuikumTransport>("*", SQLWhere, "ListNo ASC", (int)ViewBag.PageIndex, (int)ViewBag.PageSize);

            ViewBag.TotalPage = svTranport.TotalPage;
            ViewBag.TotalRow  = svTranport.TotalRow;
            ViewBag.Transport = transport;
            return(PartialView("UC/GridTransport"));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TypeOfTransportId,RoutesId,EmployeesId,Date,Change")] TransportService transportService)
        {
            if (id != transportService.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transportService);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransportServiceExists(transportService.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeesId"]       = new SelectList(_context.Employees, "Id", "Id", transportService.EmployeesId);
            ViewData["RoutesId"]          = new SelectList(_context.Routes, "Id", "Id", transportService.RoutesId);
            ViewData["TypeOfTransportId"] = new SelectList(_context.TypeOfTransport, "Id", "Id", transportService.TypeOfTransportId);
            return(View(transportService));
        }
        public DestinationPresenter(IDestinationView view, ProductModel selectedProduct)
        {
            _view = view;

            SelectedProduct = selectedProduct;

            _destinationMapper = new DestinationMapper();

            _transportMapper = new TransportMapper();

            _productMapper = new ProductMapper();

            _orderMapper = new OrderMapper();

            _orderStatusMapper = new OrderStatusMapper();

            _unitOfWork = new UnitOfWork(new ApplicationContext());

            destinationService = new DestinationService(_unitOfWork);

            transportService = new TransportService(_unitOfWork);

            orderService = new OrderService(_unitOfWork);

            OrderStatusService = new OrderStatusService(_unitOfWork);

            destinations = destinationService.GetAllDestinations().Select(dest => _destinationMapper.FromDomainToModel(dest)).ToList();

            _view.DisplayData(destinations);

            _view.DestinationSelected += BeginOrderCreation;
        }
        public MainViewModel()
        {
            ITransportService transportService = new TransportService();

            this.StationTimeTable = new StationTimeTableViewModel(transportService);
            this.SearchStation    = new SearchStationViewModel(transportService);
            this.TimeTable        = new TimeTableViewModel(transportService);
        }
Example #7
0
        // GET: Transport
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TransportService(userId);
            var model   = service.GetTransports();

            return(View(model));
        }
Example #8
0
        public FrontController(DataInitializer dataInitializer)
        {
            //unitOfWork = new UnitOfWork(new ApplicationContext());

            _transportService = new TransportService(unitOfWork);

            _productService = new ProductService(unitOfWork);

            _destinationService = new DestinationService(unitOfWork);
        }
Example #9
0
        public void init()
        {
            RattlerTransportType.init();

            stationService   = new StationService(this);
            transportService = new TransportService(this);

            store       = new RattlerStore();
            storeLoader = new RattlerStoreLoader(this);
            storeLoader.loadData();
        }
Example #10
0
        private LocalLongFullPath GetAgentLogPath(TransportService transportService)
        {
            GetAgentLog.< > c__DisplayClass3 CS$ < > 8__locals1 = new GetAgentLog.< > c__DisplayClass3();
            CS$ < > 8__locals1.session     = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 182, "GetAgentLogPath", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\AgentLog\\GetAgentLog.cs");
            CS$ < > 8__locals1.localServer = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                CS$ < > 8__locals1.localServer = CS$ < > 8__locals1.session.FindLocalServer();
            });

            if (!adoperationResult.Succeeded)
            {
                base.WriteError(adoperationResult.Exception, ErrorCategory.ReadError, null);
            }
            if (transportService == TransportService.FrontEnd)
            {
                FrontendTransportServer[] feServer = null;
                adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    feServer = (FrontendTransportServer[])CS$ < > 8__locals1.session.Find <FrontendTransportServer>(null, CS$ < > 8__locals1.localServer.Id, true, null);
                });
                if (!adoperationResult.Succeeded)
                {
                    base.WriteError(adoperationResult.Exception, ErrorCategory.ReadError, null);
                }
                if (feServer == null || feServer.Length == 0)
                {
                    base.WriteError(new LocalServerNotFoundException(string.Format("Local server does not contain transport service {0}", new object[0])), ErrorCategory.InvalidOperation, null);
                }
                return(feServer[0].AgentLogPath);
            }
            if (transportService != TransportService.MailboxDelivery && transportService != TransportService.MailboxSubmission)
            {
                return(CS$ < > 8__locals1.localServer.AgentLogPath);
            }
            MailboxTransportServer[] mbxServer = null;
            adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                mbxServer = (MailboxTransportServer[])CS$ < > 8__locals1.session.Find <MailboxTransportServer>(null, CS$ < > 8__locals1.localServer.Id, true, null);
            });
            if (!adoperationResult.Succeeded)
            {
                base.WriteError(adoperationResult.Exception, ErrorCategory.ReadError, null);
            }
            if (mbxServer == null || mbxServer.Length == 0)
            {
                base.WriteError(new LocalServerNotFoundException(string.Format("Local server does not contain transport service {0}", new object[0])), ErrorCategory.InvalidOperation, null);
            }
            if (transportService == TransportService.MailboxDelivery)
            {
                return(mbxServer[0].MailboxDeliveryAgentLogPath);
            }
            return(mbxServer[0].MailboxDeliveryAgentLogPath);
        }
Example #11
0
        private void RunAsync(Action callback)
        {
            var deviceInfoService   = new DeviceInfoService(GetInitConnection(), true, "BackgroundDifferenceLoader", _id);
            var eventAggregator     = new TelegramEventAggregator();
            var cacheService        = new InMemoryCacheService(eventAggregator);
            var updatesService      = new UpdatesService(cacheService, eventAggregator);
            var transportService    = new TransportService();
            var connectionService   = new ConnectionService(deviceInfoService);
            var publicConfigService = new MockupPublicConfigService();

            var manualResetEvent = new ManualResetEvent(false);
            var mtProtoService   = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService);

            mtProtoService.Initialized += (o, e) =>
            {
                var lastTime = TLUtils.OpenObjectFromMTProtoFile <TLInt>(_differenceTimeSyncRoot, Constants.DifferenceTimeFileName);
                if (lastTime != null)
                {
                    var now = TLUtils.DateToUniversalTimeTLInt(mtProtoService.ClientTicksDelta, DateTime.Now);

                    if (lastTime.Value + Constants.DifferenceMinInterval > now.Value)
                    {
                        manualResetEvent.Set();
                        return;
                    }
                }

                var clientState = TLUtils.OpenObjectFromMTProtoFile <TLState>(_stateRoot, Constants.StateFileName);
                _results = TLUtils.OpenObjectFromMTProtoFile <TLVector <TLDifference> >(_differenceFileSyncRoot, Constants.DifferenceFileName) ?? new TLVector <TLDifference>();
                var state = GetState(clientState, _results);

                if (state != null)
                {
                    GetDifferenceAsync(mtProtoService, state, () => manualResetEvent.Set());
                }
                else
                {
                    manualResetEvent.Set();
                }
            };
            mtProtoService.InitializationFailed += (o, e) =>
            {
                manualResetEvent.Set();
            };
            mtProtoService.Initialize();

#if DEBUG
            manualResetEvent.WaitOne(15000);
#else
            manualResetEvent.WaitOne(15000);
#endif

            callback.SafeInvoke();
        }
Example #12
0
        public async Task<IActionResult> OnGetAsync(Guid? id)
        {
            if (id == null)
                return NotFound();

            TransportService = await _context.TransportServices.FirstOrDefaultAsync(m => m.Id == id);

            if (TransportService == null)
                return NotFound();

           ViewData["CurrencyTypeId"] = new SelectList(_context.CurrencyTypes.AsNoTracking(), "Id", "Name");
           ViewData["TransportTypeId"] = new SelectList(_context.TransportTypes.AsNoTracking(), "Id", "Name");
            return Page();
        }
Example #13
0
        static int ScriptInsert3()
        {
            Transport model = new Transport()
            {
                NumborOfTransport = "A336KK", TypeOfTransport = "standart"
            };

            DateTime startTime = DateTime.Now;

            TransportService.Create(model);
            DateTime finishTime = DateTime.Now;

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Example #14
0
        public void Initialize(BackgroundTaskDeferral deferral)
        {
            if (_connection == null & _protoService == null)
            {
                VoIPCallTask.Log("Mediator initialized", "Creating proto service");

                var deviceInfoService = new DeviceInfoService();
                var eventAggregator   = new TelegramEventAggregator();
                var cacheService      = new InMemoryCacheService(eventAggregator);
                var updatesService    = new UpdatesService(cacheService, eventAggregator);
                var transportService  = new TransportService();
                var connectionService = new ConnectionService(deviceInfoService);
                var statsService      = new StatsService();
                var protoService      = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, statsService);

                protoService.Initialized += (s, args) =>
                {
                    VoIPCallTask.Log("ProtoService initialized", "waiting for updates");

                    updatesService.LoadStateAndUpdate(() =>
                    {
                        VoIPCallTask.Log("Difference processed", "Difference processed");

                        if (_phoneCall == null)
                        {
                            VoIPCallTask.Log("Difference processed", "No call found in difference");

                            if (_systemCall != null)
                            {
                                _systemCall.NotifyCallEnded();
                            }
                        }
                    });
                };

                eventAggregator.Subscribe(this);
                protoService.Initialize();
                _protoService     = protoService;
                _transportService = transportService;
            }
            else
            {
                VoIPCallTask.Log("Mediator initialized", "_connection is null: " + (_connection == null));
            }

            _deferral    = deferral;
            _initialized = true;

            ProcessUpdates();
        }
Example #15
0
        public async Task <IActionResult> Create([Bind("Id,TypeOfTransportId,RoutesId,EmployeesId,Date,Change")] TransportService transportService)
        {
            if (ModelState.IsValid)
            {
                _context.Add(transportService);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeesId"]       = new SelectList(_context.Employees, "Id", "Id", transportService.EmployeesId);
            ViewData["RoutesId"]          = new SelectList(_context.Routes, "Id", "Id", transportService.RoutesId);
            ViewData["TypeOfTransportId"] = new SelectList(_context.TypeOfTransport, "Id", "Id", transportService.TypeOfTransportId);
            return(View(transportService));
        }
Example #16
0
        static int ScriptRead3()
        {
            Transport model = TransportService.Read(new Transport()
            {
                NumborOfTransport = "A336KK", TypeOfTransport = "standart"
            }, 1, 0).First();

            DateTime  startTime  = DateTime.Now;
            Transport models     = TransportService.Read(model, 1, 0).First();
            DateTime  finishTime = DateTime.Now;

            Console.WriteLine("{0}: {1} - {2}", models.Id, models.NumborOfTransport, models.TypeOfTransport);

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
 /// <summary>
 /// Confirm the configuration saving before quit the application
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Check if the config have been change and haven't been save
     if (!CheckSaveConfig())
     {
         e.Cancel = true;
     }
     else
     {
         Hide();
         if (transportService != null)
         {
             transportService.Dispose();
             transportService = null;
         }
     }
 }
        // ##########################################################
        // ####################### Events ###########################
        // ##########################################################

        /// <summary>
        /// Load information in the Windowform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_Load(object sender, EventArgs e)
        {
            CheckExchangeInstalled();
            CheckDkimSignerAvailable();
            CheckDkimSignerInstalled();

            // Check transport service status each second
            try
            {
                transportService = new TransportService();
                transportService.StatusChanged += transportService_StatusUptated;
            }
            catch (ExchangeServerException) { }

            // Load setting from XML file
            LoadDkimSignerConfig();
        }
Example #19
0
        public static void Main(string[] args)
        {
            TransportCompany trCom       = new TaxiTransCom("Служба такси");
            TransportService compService = trCom.Create("Такси", 1);
            double           dist        = 15.5;

            Print(compService, dist);

            TransportCompany gCom = new ShipTransCom("Служба перевозок");

            compService = gCom.Create("Грузоперевозки", 2);

            double distg = 150.5;

            Print(compService, distg);

            Console.ReadKey(true);
        }
Example #20
0
        private void btUninstall_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(this, "Do you really want to UNINSTALL the DKIM Exchange Agent?\n", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    ExchangeServer.UninstallDkimTransportAgent();
                    RefreshTransportServiceAgents();
                    TransportService ts = new TransportService();
                    try
                    {
                        ts.Do(TransportServiceAction.Restart, delegate(string msg)
                        {
                            MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        });
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        ts.Dispose();
                    }
                    MessageBox.Show(this, "Transport Agent unregistered from Exchange. Please remove the folder manually: '" + Constants.DkimSignerPath + "'\nWARNING: If you remove the folder, keep a backup of your settings and keys!", "Uninstalled", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove all the settings for Exchange DKIM Signer?'", "Remove settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                     * {
                     *  if (File.Exists(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml")))
                     *      File.Delete(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml"));
                     * }*/
                    /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove the folder '" + Constants.DKIM_SIGNER_PATH + "' and all its content?\nWARNING: All your settings and keys will be deleted too!", "Remove files?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                     * {
                     *  var dir = new DirectoryInfo(Constants.DKIM_SIGNER_PATH);
                     *  dir.Delete(true);
                     * }*/
                }
                catch (ExchangeServerException ex)
                {
                    MessageBox.Show(this, ex.Message, "Uninstall error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public ActionResult Index()
        {
            TransportService svTransport = new TransportService();

            RememberURL();
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }
            else
            {
                GetStatusUser();
                SetPager();
                var Transport = svTransport.SelectData <OuikumTransport>("*", "IsDelete = 0 AND WebID = 1");
                ViewBag.Transport = Transport;
                ViewBag.TotalPage = svTransport.TotalPage;
                ViewBag.TotalRow  = svTransport.TotalRow;
                return(View());
            }
        }
Example #22
0
        // ##########################################################
        // ####################### Events ###########################
        // ##########################################################

        private void InstallWindow_Load(object sender, EventArgs e)
        {
            CheckExchangeInstalled();
            try
            {
                transportServiceActionCompleted = new AutoResetEvent(false);
                transportService = new TransportService();
                transportService.StatusChanged += transportService_StatusUptated;
            }
            catch (ExchangeServerException) { }

            if (zipUrl == null && !performInstall)
            {
                CheckDkimSignerAvailable();
            }
            else
            {
                // the dkim signer should be installed directly. Disable selection
                gbSelectVersionToInstall.Enabled = false;
            }
        }
Example #23
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            Txt_Mensaje.Text = String.Empty;
            TransportService ws = new TransportService();

            try
            {
                if (ws.Login(txt_Usuario.Text, txt_Contraseña.Text))
                {
                    Response.Redirect(url: "MasterPage/WebForm1.aspx");
                }
                else
                {
                    Txt_Mensaje.Text = "Credenciales Incorrectos";
                }
            }
            catch (Exception)
            {
                Txt_Mensaje.Text = "Ha ocurrido un problema al iniciar sesion.";
            }
        }
        public void GetAllTransports_Simple()
        {
            var db        = new Mock <IPlatformDatabase>();
            var logger    = new Mock <ILogger <TransportService> >();
            var transport = _fixture.Create <Transport>();

            var data = new List <Transport>
            {
                transport
            };

            db.Setup(x => x.Transports).ReturnsDbSet(data);

            var service = new TransportService(db.Object, logger.Object);

            var result = service.GetAllTransports(CancellationToken.None).Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(transport.Name, result.First().Name);
        }
        private void ProcessLiveLocations()
        {
            var deviceInfoService   = new Telegram.Api.Services.DeviceInfo.DeviceInfoService(GetInitConnection(), true, "BackgroundDifferenceLoader", 1);
            var cacheService        = new MockupCacheService();
            var updatesService      = new MockupUpdatesService();
            var transportService    = new TransportService();
            var connectionService   = new ConnectionService(deviceInfoService);
            var publicConfigService = new MockupPublicConfigService();

            var manualResetEvent = new ManualResetEvent(false);
            var eventAggregator  = new TelegramEventAggregator();
            var mtProtoService   = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService);

            mtProtoService.Initialized += (o, e) =>
            {
                var liveLocationsService = new LiveLocationService(mtProtoService, eventAggregator);

                liveLocationsService.Load();

                liveLocationsService.UpdateAll();

                manualResetEvent.Set();
            };
            mtProtoService.InitializationFailed += (o, e) =>
            {
                manualResetEvent.Set();
            };
            mtProtoService.Initialize();

            var timeout =
#if DEBUG
                Timeout.InfiniteTimeSpan;
#else
                TimeSpan.FromSeconds(30.0);
#endif

            var result = manualResetEvent.WaitOne(timeout);
        }
Example #26
0
        private void btDisable_Click(object sender, EventArgs e)
        {
            try
            {
                if (btDisable.Text == "Disable")
                {
                    ExchangeServer.DisableDkimTransportAgent();
                }
                else
                {
                    ExchangeServer.EnableDkimTransportAgent();
                }

                RefreshTransportServiceAgents();
                RefreshMoveButtons(true);

                TransportService ts = new TransportService();
                try
                {
                    ts.Do(TransportServiceAction.Restart, delegate(string msg)
                    {
                        MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    ts.Dispose();
                }
            }
            catch (ExchangeServerException ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #27
0
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TransportService = await _context.TransportServices
                               .Include(t => t.CurrencyType)
                               .Include(t => t.Order)
                               .Include(t => t.PacketTourService)
                               .Include(t => t.TransportType).FirstOrDefaultAsync(m => m.Id == id);

            if (TransportService == null)
            {
                return(NotFound());
            }
            ViewData["CurrencyTypeId"]      = new SelectList(_context.CurrencyTypes, "Id", "Name");
            ViewData["OrderId"]             = new SelectList(_context.Orders, "Id", "Number");
            ViewData["PacketTourServiceId"] = new SelectList(_context.PacketTourServices, "Id", "Id");
            ViewData["TransportTypeId"]     = new SelectList(_context.TransportTypes, "Id", "Name");
            return(Page());
        }
Example #28
0
        public GrpcTransportProvider(IGrpcHostConfiguration hostConfiguration, IGrpcTopologyConfiguration topologyConfiguration)
        {
            _hostConfiguration     = hostConfiguration;
            _topologyConfiguration = topologyConfiguration;

            _messageFabric = new MessageFabric();

            _nodeCollection = new NodeCollection(this, _messageFabric);
            _clients        = new List <IGrpcClient>();

            var transport = new GrpcTransportService(this, _hostConfiguration, _nodeCollection);

            _server = new Server(GetChannelOptions())
            {
                Services = { TransportService.BindService(transport) },
                Ports    = { new ServerPort(hostConfiguration.BaseAddress.Host, hostConfiguration.BaseAddress.Port, ServerCredentials.Insecure) }
            };

            var serverPort = _server.Ports.First();

            HostAddress = new UriBuilder(_hostConfiguration.BaseAddress)
            {
                Host = serverPort.Host,
                Port = serverPort.BoundPort
            }.Uri;

            HostNodeContext = new HostNodeContext(HostAddress);

            _hostNode = new GrpcHostNode(_messageFabric, HostNodeContext);

            var observer = new NodeMessageFabricObserver(_nodeCollection, _hostNode);

            _messageFabric.ConnectMessageFabricObserver(observer);

            _startupTask = new Lazy <Task>(() => Task.Run(() => Startup()));
        }
        public async Task<ActionResult> LetTheMagicBegin()
        {
            var transport = new TransportService("");

            if (transport == null)
                return RedirectToAction("Search");
            var channel = await Task.Run(() =>
            {
                TransportService.StartThePump(transport);
                //return ChannelUtilities.GetChannel(new MoonAidWebApi.Models.Owner());
            });
            // TODO: Get a ChannelViewModel and send it to DashBoard view

            return View("DashBoard", channel);
        }
Example #30
0
        private void UninstallWindow_Shown(object sender, EventArgs e)
        {
            if (
                MessageBox.Show("Uninstall Exchange DKIM Signer?", "Uninstall?", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) != DialogResult.Yes)
            {
                this.Close();
                Application.Exit();
                return;
            }

            try
            {
                lbStep.Text = "Uninstalling Exchange Agent";
                ExchangeServer.UninstallDkimTransportAgent();

                lbStep.Text = "Restarting MS Exchange Transport";
                TransportService ts = new TransportService();
                try
                {
                    ts.Do(TransportServiceAction.Restart, delegate(string msg)
                    {
                        MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    ts.Dispose();
                }


                lbStep.Text = "Deleting directory";

                if (
                    MessageBox.Show(this,
                                    "The directory '" + Constants.DkimSignerPath +
                                    "' will now be deleted. Please make a backup of the keys stored within this directory before continuing.\n Continue deleting?",
                                    "Delete directory?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        Directory.Delete(Constants.DkimSignerPath, true);
                    }
                    catch (Exception)
                    {
                        //ignore exception. Delete directory on reboot
                        if (!NativeMethods.MoveFileEx(Constants.DkimSignerPath, null, MoveFileFlags.DelayUntilReboot))
                        {
                            MessageBox.Show(
                                "Unable to schedule '" + Constants.DkimSignerPath + "' for deletion on next reboot.",
                                "Delete error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }

                lbStep.Text = "Removing registry entry";
                CplControl.Unregister();
                UninstallerRegistry.Unregister();

                /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove all the settings for Exchange DKIM Signer?'", "Remove settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                 * {
                 *  if (File.Exists(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml")))
                 *      File.Delete(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml"));
                 * }*/
                /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove the folder '" + Constants.DKIM_SIGNER_PATH + "' and all its content?\nWARNING: All your settings and keys will be deleted too!", "Remove files?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                 * {
                 *  var dir = new DirectoryInfo(Constants.DKIM_SIGNER_PATH);
                 *  dir.Delete(true);
                 * }*/
                lbStep.Text             = "Uninstall complete";
                progressUninstall.Style = ProgressBarStyle.Continuous;
                progressUninstall.Value = 100;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Uninstall error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            btClose.Enabled = true;
        }
Example #31
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            var data = Toast.GetData(taskInstance);

            if (data != null)
            {
                if (data.ContainsKey("QuickMessage"))
                {
                    var deviceInfoService = new DeviceInfoService();
                    var eventAggregator   = new TelegramEventAggregator();
                    var cacheService      = new InMemoryCacheService(eventAggregator);
                    var updatesService    = new UpdatesService(cacheService, eventAggregator);
                    var transportService  = new TransportService();
                    var connectionService = new ConnectionService(deviceInfoService);
                    var statsService      = new StatsService();
                    var manualResetEvent  = new ManualResetEvent(false);
                    var protoService      = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, statsService);

                    protoService.Initialized += (s, args) =>
                    {
                        var text         = data["QuickMessage"];
                        var messageText  = text.Replace("\r\n", "\n").Replace('\v', '\n').Replace('\r', '\n');
                        var entitiesBase = Utils.GetEntities(ref messageText);

                        var replyToMsgId = 0;
                        var inputPeer    = default(TLInputPeerBase);
                        if (data.ContainsKey("from_id"))
                        {
                            inputPeer = new TLInputPeerUser {
                                UserId = int.Parse(data["from_id"]), AccessHash = long.Parse(data["access_hash"])
                            };
                        }
                        else if (data.ContainsKey("channel_id"))
                        {
                            inputPeer = new TLInputPeerChannel {
                                ChannelId = int.Parse(data["channel_id"]), AccessHash = long.Parse(data["access_hash"])
                            };
                            replyToMsgId = data.ContainsKey("msg_id") ? int.Parse(data["msg_id"]) : 0;
                        }
                        else if (data.ContainsKey("chat_id"))
                        {
                            inputPeer = new TLInputPeerChat {
                                ChatId = int.Parse(data["chat_id"])
                            };
                            replyToMsgId = data.ContainsKey("msg_id") ? int.Parse(data["msg_id"]) : 0;
                        }

                        TLVector <TLMessageEntityBase> entities = null;
                        if (entitiesBase != null)
                        {
                            entities = new TLVector <TLMessageEntityBase>(entitiesBase);
                        }

                        var obj = new TLMessagesSendMessage {
                            Peer = inputPeer, ReplyToMsgId = replyToMsgId, Message = messageText, Entities = entities, IsBackground = true, RandomId = TLLong.Random()
                        };

                        protoService.SendInformativeMessageInternal <TLUpdatesBase>("messages.sendMessage", obj, result =>
                        {
                            manualResetEvent.Set();
                        },
                                                                                    faultCallback: fault =>
                        {
                            // TODO: alert user?
                            manualResetEvent.Set();
                        },
                                                                                    fastCallback: () =>
                        {
                            manualResetEvent.Set();
                        });

                        //var date = TLUtils.DateToUniversalTimeTLInt(protoService.ClientTicksDelta, DateTime.Now);
                        //var message = TLUtils.GetMessage(SettingsHelper.UserId, inputPeer, TLMessageState.Sending, true, true, date, text, new TLMessageMediaEmpty(), TLLong.Random(), replyToMsgId);
                        //var history = cacheService.GetHistory(inputPeer, 1);

                        //cacheService.SyncSendingMessage(message, null, async (m) =>
                        //{
                        //    await protoService.SendMessageAsync(message, () =>
                        //    {
                        //        // TODO: fast callback
                        //    });
                        //    manualResetEvent.Set();
                        //});
                    };
                    protoService.InitializationFailed += (s, args) =>
                    {
                        manualResetEvent.Set();
                    };

                    //cacheService.Init();
                    protoService.Initialize();

                    manualResetEvent.WaitOne(15000);
                }
            }

            deferral.Complete();
        }