public Status(ServiceNode serviceNode) { UIApp.PubSub.Subscribe <ProfileDataResultEvent>(this, ProfileData); ServiceNode = serviceNode; try { var data = serviceNode.CacheStorage.ReadFileBytes(GetType().Name); if (data != null) { using (var unpacker = new Unpacker(data)) { _subscriptions = new Subscriptions(unpacker, this); if (unpacker.UnpackBool()) { _subscriptionLastTransaction = new LastTransactionInfo(unpacker); } } } } catch (Exception ex) { Log.IgnoreException(ex); } if (_subscriptions == null) { _subscriptions = new Subscriptions(AccountId, ChainId, this); } }
public async Task <AcceptInvitationEvent> AcceptFriendInvitation(long friendId) { var submitAccount = ServiceNode.GetSubmitAccounts <SubmitAccount>(MessageServiceInfo.SubmitAccountIndex).FirstOrDefault(); var result = await SetSubmitAccount(submitAccount); if (result != null) { goto end; } var transaction = NewFriendTransaction(AccountId, ChainId, FriendRequestMode.AcceptInvitation, friendId); result = await _client.SendDataTransaction(transaction, true); if (result.TransactionResult == TransactionResultTypes.Ok) { UIApp.Run(() => DownloadFriends(false)); } end: var @event = new AcceptInvitationEvent(friendId, this, result); await UIApp.PubSub.PublishAsync(@event); return(@event); }
public IActionResult ForgotPasswordData([FromForm] IdentityDTO request) { #region ForgotPassword ReturnMessage <ForgotPasswordDTO> response = new ServiceNode <IdentityDTO, ForgotPasswordDTO>(_localizer, _fc).PostClient(request, "/api/v1/users/getusertoken"); if (response.IsCatched == 1) { TempData["ServerResponseError"] = response.Message; return(RedirectToAction("ForgotPassword")); } TempData["SuccessResponse"] = _localizer["We send password restore link to your email, please check your email adress"].ToString(); #region SendRestoreEmail var configUrl = _configuration["BaseUrl"] + $"/users/restore?uk={response.Data.Token}&&pk={response.Data.Password}"; MailSender.SendEmail( "TCYDM", "*****@*****.**", response.Data.Name, response.Data.Email, "Restore Password", "<a href =" + configUrl + ">Restore account</a>", "*****@*****.**", "o1o2o3o4o5o6o7o8o9o10" ); #endregion #endregion return(RedirectToAction("Login", "Users")); }
public IActionResult UserRegister([FromForm] UserDTO request) { #region Register Body ReturnMessage <EmailConfirmationDTO> response = new ServiceNode <UserDTO, EmailConfirmationDTO>(_localizer, _fc).PostClient(request, "/api/v1/users/register"); if (response.IsCatched == 1) { TempData["ServerResponseError"] = response.Message; return(RedirectToAction("Login")); } TempData["SuccessResponse"] = _localizer["We send confirmation email to your email adress, please confirm it is actually your email.After confirmation you can access your account"].ToString(); #region SendConfirmationEmail var configUrl = _configuration["BaseUrl"] + $"/users/userconfirm?uk={response.Data.Token}&&pk={response.Data.Password}"; MailSender.SendEmail( "TCYDM", "*****@*****.**", request.Name, request.Email, "Email Confirmation", "<a href =" + configUrl + ">Confirm email</a>", "*****@*****.**", "o1o2o3o4o5o6o7o8o9o10" ); #endregion #endregion return(RedirectToAction("Login", "Users")); }
private string baseForwardAddress; // = "http://localhost:1177/"; #endregion /// <summary> /// Create a ServiceNodeCore and initialize its fields. /// </summary> /// <param name="serviceNode">represents the ServiceNode and its settings.</param> public ServiceNodeCore(ServiceNode serviceNode) { this.serviceNode = serviceNode; // Create a new instance of the service implementor. serviceImpl = new DarPoolingService(this); mobileServiceImpl = new DarPoolingServiceMobile(serviceImpl); //serviceImpl.SetMobileHandler = mobileServiceImpl; // Set the delegates removeJoinedUser = new RemoveJoinedUser(serviceImpl.RemoveJoinedUser); string serviceIP = "localhost"; baseHTTPAddress = "http://" + serviceIP + ":1111/"; baseMobileAddress = "http://" + serviceIP + ":1155/"; baseForwardAddress = "http://" + serviceIP + ":1177/"; //Console.WriteLine("Final addresses are:\n {0}\n{1}\n{2}",baseHTTPAddress, baseMobileAddress, baseForwardAddress); InitializeXmlDatabases(); }
public IActionResult ServiceInfo(int serviceId) { #region ServiceData int langId = 1; if (Request.Cookies["LangKey"] != null) { langId = Convert.ToInt32(Request.Cookies["LangKey"]); } OurServicesDTO prms = new OurServicesDTO(); ServiceInfo service = new ServiceInfo(); Task tsk1 = Task.Factory.StartNew(() => { prms = new ServiceNode <object, OurServicesDTO>(_fc) .GetClient("/api/v1/OurServices/OurServicesGetById/" + serviceId + "/" + langId).Data; }); Task tsk2 = Task.Factory.StartNew(() => { service = new ServiceNode <object, ServiceInfo>(_fc) .GetClient("/api/v1/serviceinfo/get/" + serviceId + "/" + langId).Data; }); Parallel.Invoke(); tsk1.Wait(); tsk2.Wait(); ServiceInfoViewModel model = new ServiceInfoViewModel(); model.ServiceInfo = service; model.ServiceParams = prms; #endregion return(View("ServiceInfo", model)); }
private void LoadModel() { //// Variáveis aleatórias primárias object syncRede = new object(); long qtdNodosPendentes = 0; long teste = 0; do { object sync = new object(); qtdNodosPendentes = 0; Parallel.ForEach(_redeBayesiana.Nodes, () => 0, (node, loop, pendentes) => { ServiceNode serviceNode = new ServiceNode(ref node, ref _redeBayesiana); lock (syncRede) { bool _validParents = serviceNode.ValidParents; if (node.situacaoNodo == 0 && _validParents) { serviceNode.SetState(node.Id, (int)Node.Estado.Carregado); node.NodeParents = serviceNode.NodeParents; serviceNode.LoadNode(); serviceNode.SetState(node.Id, (int)Node.Estado.Finalizado); } if (!_validParents) { pendentes++; } } return(pendentes); }, (finalResult) => Interlocked.Add(ref qtdNodosPendentes, finalResult) ); teste += qtdNodosPendentes; } while (qtdNodosPendentes != 0); }
MessageSubmitAccount GenerateSubmitAccount(Chain.Index index) { (var friendAccountId, var friendKeyIndex, var accountId, var keyIndex) = GetFriendAccountId(index); if (accountId != AccountId) { return(null); } var submitAccount = ServiceNode.GetSubmitAccount <MessageSubmitAccount>(keyIndex, index); if (submitAccount != null) { return(submitAccount); } foreach (var account in ServiceNode.ServiceAccounts.Values) { if (!account.IsDecrypted) { continue; } if (account.AccountId == accountId && account.KeyIndex == keyIndex) { submitAccount = new MessageSubmitAccount(account, this, friendAccountId, friendKeyIndex, keyIndex, index, true); ServiceNode.AddSubmitAccount(submitAccount); return(submitAccount); } } return(null); }
public IActionResult Delete([FromQuery] int query_id) { var req = new ServiceNode <object, object>(_localizer, _fc).DeleteClient($"/api/services/delete/{query_id}"); TempData["R_Message"] = "Silindi"; return(RedirectToAction("Services", "Home", new { Area = "Admin" })); }
public Guid SetInterval(JavaScriptValue callback, int delay) { if (callback.ValueType != JavaScriptValueType.Function) { throw new ArgumentException("SetInterval only accepts javascript function"); } CancellationTokenSource source = new CancellationTokenSource(); Guid id = addCallback(callback, source); Action a = ServiceNode.GetService <IJSValueConverterService>().FromJSValue <Action>(callback); Task.Factory.StartNew(async() => { while (true) { try { await Task.Delay(delay, source.Token); a(); } catch (OperationCanceledException) { return; } catch (Exception) { throw; } } }, source.Token); return(id); }
public IActionResult Doctors([FromQuery] int page = 0) { int pagecount = page; var services = new ServiceNode <object, DoctorViewModel>(_fc).GetClient("/api/doctors/all/admin/" + pagecount); return(View("Doctors", services.Data)); }
public IActionResult EditConfirm([FromForm] DoctorAddForm request) { #region EditDoctorInfo List <LangDTO> langs = new ServiceNode <object, List <LangDTO> >(_fc).GetClient("/api/lang/all").Data; DoctorAdd doctor = new DoctorAdd(); doctor.DoctorLevel = request.DoctorLevel; doctor.Sex = request.Sex; doctor.ServiceId = request.ServiceId; doctor.Name = request.Name; doctor.LevelType = request.LevelType; List <InfoStr> infostrs = new List <InfoStr>(); List <IstanbulNsApp.Areas.Admin.Models.Phone> phones = new List <IstanbulNsApp.Areas.Admin.Models.Phone>(); for (int i = 0; i < langs.Count; i++) { infostrs.Add(new InfoStr { LangId = langs[i].Id, Info = request.InfoStrs[i] }); } for (int i = 0; i < request.Phones.Count; i++) { phones.Add(new IstanbulNsApp.Areas.Admin.Models.Phone { PhoneNumber = request.Phones[i] }); } string pictureName = string.Empty; if (request.Picture != null) { if (request.ExistedPicture != null) { FileManager.Delete(request.ExistedPicture, "DoctorPictures"); } pictureName = FileManager.IFormSaveLocal(request.Picture, "DoctorPictures"); } doctor.InfoStrs = infostrs; doctor.Picture = pictureName; /// DoctorInfos DoctorsInfo dcInfo = new DoctorsInfo(); dcInfo.Location = request.Location; dcInfo.Phones = phones; dcInfo.WorkTimeFromDate = request.WorkTimeFromDate; dcInfo.WorkTimeToDate = request.WorkTimeToDate; dcInfo.WorkTimeToTime = request.WorkTimeToTime; dcInfo.WorkTimeFromTime = request.WorkTimeFromTime; dcInfo.Email = request.Email; doctor.DoctorsInfos = dcInfo; var req = new ServiceNode <DoctorAdd, object>(_localizer, _fc).PostClient(doctor, $"/api/doctors/update/{request.Id}"); if (req.IsCatched == 1) { return(RedirectToAction("Edit")); } #endregion TempData["R_Message_Doc"] = "Dəyişdirildi"; return(RedirectToAction("Doctors", "Home")); }
public StatusAccountPage(ProfileDataResult profileData, ServiceNode serviceNode, long accountId, StatusAccountProfileType profileType, long transactionId) : base("StatusAccountPage") { Subscribe <SubscriptionEvent>(Subscription); Subscribe <ProfileDataResultEvent>(ProfileData); StackLayout.Suspended = true; _transactionId = transactionId; _profileType = profileType; _serviceNode = serviceNode; _status = StatusApp.Current.GetStatus(serviceNode); _accountId = accountId; _accountIndex = Chain.Index.New().Add(_accountId).Build(); _messagesDownload = new AccountIndexTransactionDownload(accountId, StatusServiceInfo.MessageIndex, serviceNode.GetTransactionDownloadManager(StatusServiceInfo.StatusDataChainIndex)) { Count = 10 }; AddTitleRow("Title"); if (profileType == StatusAccountProfileType.Small || transactionId > 0) { var row = new StatusProfileButtonRow(serviceNode, _accountId, profileData?.ProfileInfo, profileData, async(button) => { await Navigation.PushAsync(new StatusAccountPage(profileData, serviceNode, accountId, StatusAccountProfileType.Big, transactionId)); }, false); AddRow(row); } if (profileType == StatusAccountProfileType.Big && transactionId <= 0) { if (_status != null) { AddHeaderRow("Subscription"); _subscribe = AddSwitchRow("Subscribe"); _subscribe.Switch.IsToggled = _status.IsSubscribed(_accountId); _subscribe.Switch.ToggledAsync = Subscribe_Toggled; _subscribe.SetDetailViewIcon(Icons.Check); _notification = AddSwitchRow("Notification"); _notification.Switch.IsToggled = UIApp.Current.IsPushChannelSubscribed(_accountIndex); _notification.Switch.ToggledAsync = Notification_Toggled; _notification.SetDetailViewIcon(Icons.Bell); AddFooterRow(); } if (profileData == null || profileType == StatusAccountProfileType.Big) { UIApp.Run(() => ProfileManager.Current.GetProfileData(_accountId, ProfileDownloadType.ForceDownload, true)); } } IsBusy = true; }
public async Task QueryTodoLists(ServiceNode serviceNode) { var todo = GetTodo(serviceNode); if (todo != null) { await todo.QueryTodoLists(); } }
public async Task Register(ServiceNode local) { LocalNode = local; using (var session = _documentStore.LightweightSession()) { session.Store(LocalNode); await session.SaveChangesAsync(); } }
public IActionResult NewQuery() { var servis = new ServiceNode <object, OnlineTurnDTO>(_fc).GetClient("/api/online_query/info/3/1"); var services = new ServiceNode <object, List <ServiceDTO> >(_fc).GetClient("/api/services/services/1"); var model = new OnlineTurnAddViewModel(); model.OnlineData = servis.Data; model.Services = services.Data; return(View(model)); }
public IViewComponentResult Invoke() { var UserId = Convert.ToInt32(Request.Cookies["UserKey"]); UserDTO model = new ServiceNode <object, UserDTO>(_fc) .GetClient("/api/v1/users/getuser/raw/" + UserId).Data; return(View(model)); }
public IActionResult AddResult([FromForm] OnlineTurnVm req) { var filename = FileManager.IFormSaveLocal(req.File, "OnlineQuerieResults"); FileName fileName = new FileName(); fileName.FileNameData = filename; var client = new ServiceNode <OnlineTurnVm, object>(_fc).PostClient(fileName, $"/api/online_query/add/result/{req.query_id}"); return(RedirectToAction("OnlineTurnSection")); }
private Guid addCallback(JavaScriptValue value, CancellationTokenSource source) { Guid result = Guid.NewGuid(); ServiceNode.WithContext(() => { value.AddRef();//hold the callback function }); list.Add(result, new Tuple <JavaScriptValue, CancellationTokenSource>(value, source)); return(result); }
/* Visiting methods */ protected internal override void VisitServiceNode(ServiceNode node, object data) { StackTypes stack = data as StackTypes; AddTask(node.Next, stack); for (int i = 1; i < node.NextArray.Count; i++) { AddTask(node.NextArray[i], stack.Clone()); } //Service nodes do not change the stack }
public void use_tcp_endpoint_as_local_uri_if_no_http_exists() { var node = new ServiceNode { HttpEndpoints = new Uri[0], TcpEndpoints = new Uri[] { "tcp://machine1:2678".ToUri() }, MessagesUrl = "messages" }; node.DetermineLocalUri().ShouldBe("tcp://machine1:2678".ToUri()); }
public Task Register(ServiceNode local) { LocalNode = local; var consulKey = toConsulKey(); return(client.KV.Put(new KVPair(consulKey) { Value = serialize(LocalNode) })); }
public IActionResult Add() { #region LoadAddData List <LangDTO> langs = new ServiceNode <object, List <LangDTO> >(_fc).GetClient("/api/lang/all").Data; List <ServiceDTO> services = new ServiceNode <object, List <ServiceDTO> >(_fc).GetClient("/api/services/services/1").Data; var model = new DoctorAddViewModel(); model.Langs = langs; model.Services = services; #endregion return(View(model)); }
public HandleInvitationPage(ServiceNode serviceNode, InvitationSchemeAction invitation) : base("HandleInvitationPage") { Subscribe <TodoListInvitationAcceptedEvent>(InvitationAccepted); _invitation = invitation; _serviceNode = serviceNode; AddTitleRow("Title"); IsBusy = true; }
public IActionResult EditUserData([FromForm] UserDTO request) { #region Edit User var UserId = Convert.ToInt32(Request.Cookies["UserKey"]); ReturnMessage <object> response = new ServiceNode <UserDTO, object>(_localizer, _fc).PutClient(request, "/api/v1/users/update/" + UserId, HttpContext.Session.GetString("JwtSession")); if (response.IsCatched == 1) { TempData["ServerResponseError"] = response.Message; return(RedirectToAction("UserEdit")); } #endregion return(Redirect("/")); }
private void releaseCallback(Guid id) { if (!list.ContainsKey(id)) { return;//ignore the request if id does not exists } ServiceNode.WithContext(() => { list[id].Item1.Release(); //release the callback function reference }); list[id].Item2.Cancel(); //cancel the interval loop list.Remove(id); }
public IActionResult Update([FromQuery] int query_id) { #region GetUpdatedData var client = new ServiceNode <object, List <LangDTO> >(_fc); var service = client.GetClient("/api/lang/all"); var req = new ServiceNode <object, ServiceDTOAdmin>(_fc).GetClient($"/api/services/get/{query_id}"); List <LangDTO> langs = service.Data; UpdateServiceViewModel model = new UpdateServiceViewModel(); model.Langs = langs; model.Services = req.Data; #endregion return(View(model)); }
public IActionResult ChangePasswordData([FromForm] ChangePassword request) { #region ChangePasswordBody ReturnMessage <object> response = new ServiceNode <ChangePassword, object>(_localizer, _fc).PostClient(request, "/api/v1/users/change_password"); if (response.IsCatched == 1) { TempData["ServerResponseError"] = response.Message; return(RedirectToAction("ChangePassword")); } TempData["SuccessResponse"] = _localizer["Your Password Successfully Changed"].ToString(); #endregion return(RedirectToAction("Login", "Users")); }
public IActionResult Edit([FromQuery] int doctorId) { #region LoadEditableData DoctorAdmin doctors = new ServiceNode <object, DoctorAdmin>(_fc).GetClient($"/api/doctors/get/{doctorId}").Data; List <LangDTO> langs = new ServiceNode <object, List <LangDTO> >(_fc).GetClient("/api/lang/all").Data; List <ServiceDTO> services = new ServiceNode <object, List <ServiceDTO> >(_fc).GetClient("/api/services/services/1").Data; var model = new DoctorUpdateViewModel(); model.Langs = langs; model.Services = services; model.DoctorsBase = doctors; #endregion return(View(model)); }
public IActionResult DoctorInfo([FromQuery] int doctorId) { DoctorAdmin doctors = new ServiceNode <object, DoctorAdmin>(_fc).GetClient($"/api/doctors/get/{doctorId}").Data; QueryCount count = new ServiceNode <object, QueryCount>(_fc).GetClient($"/api/online_query/query/count/{doctorId}").Data; List <Lang> langs = new ServiceNode <object, List <Lang> >(_fc).GetClient("/api/lang/all").Data; var model = new DoctorsViewModel(); model.QCount = count.QCount; model.Doctor = doctors; model.Languages = langs; ViewData["DoctorId"] = doctorId; return(View(model)); }
private void PopulateClients(ServiceNode serviceNode) { if (clientBrowser != null) { clientBrowser.ServiceAdded -= new ServiceBrowseEventHandler (HandleServiceAdded); clientBrowser.ServiceRemoved -= new ServiceBrowseEventHandler (HandleServiceRemoved); clientBrowser.Dispose(); clientBrowser = null; } try { clientBrowser = new ServiceBrowser (); } catch (Exception e) { Console.WriteLine (e.ToString ()); return; } clientNodes.Clear(); clientBrowser.ServiceAdded += new ServiceBrowseEventHandler (HandleServiceAdded); clientBrowser.ServiceRemoved += new ServiceBrowseEventHandler (HandleServiceRemoved); clientBrowser.Browse (serviceNode.Type, "local"); }