public override void OnResponse(BinaryReader reader) { var code = reader.ReadUInt32(); // if contactsNotModified then exit if (code == 0xb74ba9d2) { return; } reader.ReadInt32(); // vector code var contactLen = reader.ReadInt32(); Contacts = new List <Contact>(contactLen); for (var importedIndex = 0; importedIndex < contactLen; importedIndex++) { var importedElement = TL.Parse <Contact>(reader); this.Contacts.Add(importedElement); } reader.ReadInt32(); // vector code var usersLen = reader.ReadInt32(); Users = new List <User>(usersLen); for (var usersIndex = 0; usersIndex < usersLen; usersIndex++) { var usersElement = TL.Parse <User>(reader); this.Users.Add(usersElement); } }
private async Task StartUploadPhoto(string name, Stream stream) { try { // Deployment.Current.Dispatcher.BeginInvoke(() => { // UploadProgressBar.Visibility = Visibility.Collapsed; // }); logger.info("START upload photo"); if (!(model is DialogModelPlain)) { return; } DialogModelPlain plainModel = (DialogModelPlain)model; InputFile file = await TelegramSession.Instance.Files.UploadFile(name, stream, delegate { }); InputMedia media = TL.inputMediaUploadedPhoto(file); logger.info("END upload photo"); Deployment.Current.Dispatcher.BeginInvoke(() => { logger.info("Send media in UI thread"); plainModel.SendMedia(media); }); // Deployment.Current.Dispatcher.BeginInvoke(() => { // UploadProgressBar.Visibility = Visibility.Collapsed; // }); } catch (Exception ex) { logger.error("exception {0}", ex); } }
void initStars(int N) { //first get all the masses from the IMF, and calculate the cluster mass //also set the radii and luminosities cls0.Mcl = 0.0f; for (int i = 0; i < N; i++) { float m = KTGmass(); float r = MSRadFromMass(m); float L = MSLumFromMass(m); cls0.Mcl += m; cls0.mrl_data[i * 4] = m; //solMass m(t) cls0.mrl_data[i * 4 + 1] = m; //solMass m(t=0) cls0.mrl_data[i * 4 + 2] = r; //solRad cls0.mrl_data[i * 4 + 3] = L; //solLum TL t = tlgb(m, L); cls0.tgb_data[i * 4] = Mathf.Clamp(t.times[0], 0.0f, 14000f); //tbrgb Myr cls0.tgb_data[i * 4 + 1] = Mathf.Clamp(t.times[1], 0.0f, 14000f); //tbHe Myr cls0.tgb_data[i * 4 + 2] = Mathf.Clamp(t.times[2], 0.0f, 14000f); // tbagb Myr cls0.tgb_data[i * 4 + 3] = Mathf.Clamp(t.times[3], 0.0f, 14000f); // trem Myr cls0.lgb_data[i * 4] = t.lums[0]; //tbrgb no evolution on MS for now cls0.lgb_data[i * 4 + 1] = t.lums[1]; //lbHe cls0.lgb_data[i * 4 + 2] = t.lums[2]; //lbAGB, cls0.lgb_data[i * 4 + 3] = t.lums[3]; //lrem (=0 for now) //if (m > 5) Debug.Log(m+" "+L+" "+t.times[0]+" "+t.times[1]+" "+t.times[2]+" "+t.times[3]); //Debug.Log(m+" "+L+" "+cls.tgb_data[i*4]+" "+cls.tgb_data[i*4 + 1]+" "+cls.tgb_data[i*4 + 2]+" "+cls.tgb_data[i*4 + 3]); } }
public async void SetSL(SL sL) { if (EditMode == false) { SLStandardDescriptionListViewModel.SLStandardDescriptions = new ObservableCollection <SLStandardDescription>(); } SL = Mapper.Map <SL, EditableSL>(sL); OldSL = Mapper.Map <SL, EditableSL>(sL); SL.ValidationDelegate += SL_ValidationDelegate; SL.ErrorsChanged += RaiseCanExecuteChanged; var selectedDLTypes1 = EnumHelper.GetFlags(sL.DLType1).ToList(); var selectedDLTypes2 = EnumHelper.GetFlags(sL.DLType2).ToList(); DLTypes = new ObservableCollection <DLType>(await _dLTypesService.GetDLTypesAsync()); SL.TLId = null; SelectedTL = null; //foreach (var item in selectedDLTypes1) //{ // var dLTypeId = Convert.ToInt32(item); // SelectedDLTypes1.Add(new DLType // { // DLTypeId = dLTypeId, // DLTypeTitle = (await _dLTypesService.GetDLTypeIdAsync(dLTypeId)).DLTypeTitle // }); //} //foreach (var item in selectedDLTypes2) //{ // var dLTypeId = Convert.ToInt32(item); // SelectedDLTypes2.Add(new DLType // { // DLTypeId = dLTypeId, // DLTypeTitle = (await _dLTypesService.GetDLTypeIdAsync(dLTypeId)).DLTypeTitle // }); //} }
public Task Save(Taglist ToSave, Lock Lock) { Initialize(); TaglistRepositoryLock DataFileLock = Lock as TaglistRepositoryLock; if (DataFileLock is null) { throw new ArgumentException("The supplied Lock was not returned by this class"); } if (DataFileLock.Released) { throw new ArgumentException("The supplied Lock has been released"); } try{ XDocument DataDocument = DataFileLock.LoadedDataDocument; XElement OldTaglistElement = ( from TL in DataDocument.Root.Elements(xmlns + "Taglist") where ToSave.Name.Equals( ((string)TL.Attribute("Name")).Normalize(NormalizationForm.FormKD), StringComparison.Ordinal ) select TL ).FirstOrDefault(); if (!(OldTaglistElement is null)) { OldTaglistElement.Remove(); } XElement NewTaglistElement = ToTaglistXML(ToSave); DataDocument.Root.Add(NewTaglistElement); return(XMLDataFileHandler.Save(DataDocument, SavingOptions, DataFileLock.Decorated)); }finally{ DataFileLock.Release(); } }
public DialogModelPlain(Peer peer, TelegramSession session) : base(session) { this.dialog = (DialogConstructor)TL.dialog(peer, 0, 1); SubscribeToDialog(); }
public override void OnResponse(BinaryReader reader) { var dataCode = reader.ReadUInt32(); //0xf6b673a4 SessionExpires = reader.ReadInt32(); user = TL.Parse <User>(reader); }
public override async Task RemoveAndClearDialog() { try { await ClearDialogHistory(); if (dialog.peer.Constructor == Constructor.peerChat) { InputPeer peer = InputPeer; InputPeerChatConstructor peerChat = (InputPeerChatConstructor)peer; InputUser user = TL.inputUserSelf(); messages_StatedMessage message = await session.Api.messages_deleteChatUser(peerChat.chat_id, user); switch (message.Constructor) { case Constructor.messages_statedMessage: session.Updates.processUpdatePtsSeq(((Messages_statedMessageConstructor)message).pts, ((Messages_statedMessageConstructor)message).seq); break; case Constructor.messages_statedMessageLink: session.Updates.processUpdatePtsSeq(((Messages_statedMessageLinkConstructor)message).pts, ((Messages_statedMessageLinkConstructor)message).seq); break; } } session.Dialogs.Model.Dialogs.Remove(this); } catch (Exception ex) { logger.error("exception: {0}", ex); } }
private async Task UpdateUserSettings() { if (_updateInProgress) { return; } // LOCK ON THIS _updateInProgress = true; logger.debug("Synchronizing settings"); try { InputPeerNotifySettings newSettings = TL.inputPeerNotifySettings(peerNotifySettings.mute_until, peerNotifySettings.sound, peerNotifySettings.show_previews, peerNotifySettings.events_mask); // FIXME: catch exception, process BOOl error bool update = await TelegramSession.Instance.Api.account_updateNotifySettings(TL.inputNotifyPeer (TL.inputPeerContact(Id)), newSettings); logger.debug("Synchronized settings: " + update); } catch (MTProtoException ex) { logger.error("UpdateUserSettings Exception"); } // UNLOCK ON THIS _updateInProgress = false; }
public DialogModelPlain(MessageModelDelivered topMessage, TelegramSession session) : base(session) { this.dialog = (DialogConstructor)TL.dialog(topMessage.Peer, topMessage.Id, 1); this.messages.Add(topMessage); SubscribeToDialog(); }
private async Task GetUserSettings() { if (_getInProgress) { return; } _getInProgress = true; // FIXME: catch exception await TelegramSession.Instance.Established; try { PeerNotifySettings settings = await TelegramSession.Instance.Api.account_getNotifySettings( TL.inputNotifyPeer(TL.inputPeerContact(Id))); switch (settings.Constructor) { case Constructor.peerNotifySettings: UpdatePeerNotifySettings(settings as PeerNotifySettingsConstructor); break; case Constructor.peerNotifySettingsEmpty: logger.error("Unable to get USER settings: Constructor.peerNotifySettingsEmpty"); break; } } catch (MTProtoException ex) { logger.error("GetUserSettings Exception"); } _getInProgress = false; }
private async Task StartUploadPhoto(string name, Stream stream) { try { Deployment.Current.Dispatcher.BeginInvoke(() => { UploadProgressBar.Visibility = Visibility.Collapsed; }); InputFile file = await TelegramSession.Instance.Files.UploadFile(name, stream, PhotoUploadProgressHandler); photos_Photo photo = await TelegramSession.Instance.Api.photos_uploadProfilePhoto(file, "", TL.inputGeoPointEmpty(), TL.inputPhotoCropAuto()); Photos_photoConstructor photoConstructor = (Photos_photoConstructor)photo; foreach (var user in photoConstructor.users) { TelegramSession.Instance.SaveUser(user); } Deployment.Current.Dispatcher.BeginInvoke(() => { UploadProgressBar.Visibility = Visibility.Collapsed; }); } catch (Exception ex) { logger.error("exception {0}", ex); } }
public async Task <TL> AddTLAsync(TL tL) { _uow.TLs.Add(tL); await _uow.SaveChangesAsync().ConfigureAwait(false); return(tL); }
public Telescope(string telescopeId) : base(telescopeId) { if (DriverLoader.AscomInterfaces(Impl.GetType()).Contains(typeof(ITelescopeV3))) { isPlatform6Telescope = true; } TL.LogMessage("Telescope", "Platform 5 Telescope: " + isPlatform5Telescope.ToString() + " Platform 6 Telescope: " + isPlatform6Telescope.ToString()); }
private void OnCheckinClick(object sender, EventArgs e) { InputGeoPoint point = TL.inputGeoPoint(selectedPushpin.GeoCoordinate.Latitude, selectedPushpin.GeoCoordinate.Longitude); InputMedia geoMedia = TL.inputMediaGeoPoint(point); PhoneApplicationService.Current.State["MapMedia"] = geoMedia; NavigationService.Navigate(new Uri("/UI/Pages/DialogPage.xaml?modelId=" + returnToModelId + "&action=sendMedia&content=MapMedia", UriKind.Relative)); }
public override void OnResponse(BinaryReader reader) { var code = reader.ReadUInt32(); // upload.file#96a18d5 type = TL.Parse <storage_FileType>(reader); mtime = reader.ReadInt32(); bytes = Serializers.Bytes.read(reader); }
public void SetTL(TL tL) { //TL.Text = SelectedGL?.GLCode?.ToString(); TL = Mapper.Map <TL, EditableTL>(tL); TL.ValidationDelegate += TL_ValidationDelegate; TL.ErrorsChanged += RaiseCanExecuteChanged; }
void BTree() { int x = (int)(Math.Pow(2, N) - 1); for (int i = 0; i <= x; i++) { TL.Add(Convert.ToString(i, 2).PadLeft(N, '0')); } }
public async Task <string> DownloadVideo(Video arg, FileUploadProcessHandler handler) { if (arg.Constructor == Constructor.videoEmpty) { return(null); } VideoConstructor video = (VideoConstructor)arg; TLApi api = await session.GetFileSession(video.dc_id); InputFileLocation inputFile = TL.inputVideoFileLocation(video.id, video.access_hash); string videoPath = GetVideoPath(video); string tempVideoPath = videoPath + ".tmp"; int allSize = video.size; int chunkSize = 128 * 1024; int chunksCount = allSize / chunkSize; int lastChunkSize = allSize - chunkSize * chunksCount; int allChunksCount = chunksCount + (lastChunkSize != 0 ? 1 : 0); using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(videoPath)) { return(videoPath); } using (Stream stream = new IsolatedStorageFileStream(tempVideoPath, FileMode.OpenOrCreate, FileAccess.Write, storage)) { for (int i = 0; i < chunksCount; i++) { handler((float)i * (float)chunkSize / (float)allSize); Upload_fileConstructor chunk = (Upload_fileConstructor)await api.upload_getFile(inputFile, i *chunkSize, chunkSize); stream.Write(chunk.bytes, 0, chunk.bytes.Length); } if (lastChunkSize != 0) { handler((float)chunksCount * (float)chunkSize / (float)allSize); Upload_fileConstructor lastChunk = (Upload_fileConstructor)await api.upload_getFile(inputFile, chunksCount *chunkSize, lastChunkSize); stream.Write(lastChunk.bytes, 0, lastChunk.bytes.Length); } handler(1.0f); } if (storage.FileExists(videoPath)) { storage.DeleteFile(videoPath); } storage.MoveFile(tempVideoPath, videoPath); } return(videoPath); }
public TLListViewModel(ISystemAccountingSettingsService systemAccountingSettingsService, ICompanyInformationsService companyInformationsService) { _companyInformationsService = companyInformationsService; CompanyInformationModel = _companyInformationsService.GetCompanyInformationModel(); _systemAccountingSettingsService = systemAccountingSettingsService; AddTLCommand = new RelayCommand(OnAddTL); GLsDropDownOpenedCommand = new RelayCommand(OnGLsDropDownOpened, () => GLs != null && GLs.Any()); TL = new TL(); _accessUtility = SmObjectFactory.Container.GetInstance <AccessUtility>(); }
public ActionResult TestLog(TL abc) { var d = new TL() { Id = 1, Name = $"吵架了:{Guid.NewGuid().ToString()}" }; return(new JsonResult(d)); }
private void Read(BinaryReader reader) { fromId = reader.ReadInt32(); toId = reader.ReadInt32(); date = reader.ReadInt32(); output = reader.ReadBoolean(); unread = reader.ReadBoolean(); message = TL.Parse <DecryptedMessage>(reader); file = TL.Parse <EncryptedFile>(reader); }
private bool HandleUpdate(ulong messageId, int sequence, BinaryReader messageReader) { try { UpdatesEvent(TL.Parse <Updates>(messageReader)); return(true); } catch (Exception e) { logger.warning("update processing exception: {0}", e); return(false); } }
public void read(BinaryReader reader) { logger.info("read session..."); id = reader.ReadUInt64(); sequence = reader.ReadInt32(); mainDcId = reader.ReadInt32(); timeOffset = reader.ReadInt32(); cachedSalt = reader.ReadUInt64(); int count = reader.ReadInt32(); // contacts sync marker ContactsStateMarker = Serializers.String.read(reader); dcs = new Dictionary <int, TelegramDC>(count); for (int i = 0; i < count; i++) { int endpointId = reader.ReadInt32(); dcs.Add(endpointId, new TelegramDC(reader)); } int authorizationExists = reader.ReadInt32(); if (authorizationExists != 0) { authorization = (Auth_authorizationConstructor)TL.Parse <auth_Authorization>(reader); } int usersCount = reader.ReadInt32(); users = new Dictionary <int, UserModel>(usersCount + 10); for (int i = 0; i < usersCount; i++) { users.Add(reader.ReadInt32(), new UserModel(TL.Parse <User>(reader))); } int chatsCount = reader.ReadInt32(); chats = new Dictionary <int, ChatModel>(chatsCount + 10); for (int i = 0; i < chatsCount; i++) { chats.Add(reader.ReadInt32(), new ChatModel(TL.Parse <Chat>(reader))); } logger.info("reading updates state...."); updates = new UpdatesProcessor(this, reader); logger.info("reading dialogs..."); dialogs = new Dialogs(this, reader); files = new Files(this); encryptedChats = new EncryptedChats(this, reader); logger.info("session readed complete"); }
public override void OnResponse(BinaryReader reader) { var code = reader.ReadUInt32(); if (code != 0xd07ae726 && code != 0xa9af2881) { throw new InvalidOperationException($"Expected Tl messages_StatedMessage type"); } StatedMessage = TL.Parse <messages_StatedMessage>(reader); }
public void AddDefaults() //ДОПИСАТЬ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! { Team t = new Team("Первая команда"); t.AddDefaults(); TL.Add(t); t = new Team("Вторая команда"); t.AddDefaults2(); TL.Add(t); }
private void ProcessUpdate(UpdateShortChatMessageConstructor update) { logger.info("processing short chat message: {0}", update); if (!processUpdatePtsSeqDate(update.pts, update.seq, update.date)) { return; } Message message = TL.message(update.id, update.from_id, TL.peerChat(update.chat_id), false, true, update.date, update.message, TL.messageMediaEmpty()); NewMessageEvent(message); }
public override void OnResponse(BinaryReader reader) { bool dialogsSlice = reader.ReadUInt32() == 0x71e094f3; // else dialogs#15ba6c40 if (dialogsSlice) { count = reader.ReadInt32(); // count } // dialogs var result = reader.ReadUInt32(); // vector#1cb5c415 int dialogs_len = reader.ReadInt32(); dialogs = new List <Dialog>(dialogs_len); for (int dialogs_index = 0; dialogs_index < dialogs_len; dialogs_index++) { Dialog dialog_element; dialog_element = TL.Parse <Dialog>(reader); dialogs.Add(dialog_element); } // messages result = reader.ReadUInt32(); // vector#1cb5c415 int messages_len = reader.ReadInt32(); messages = new List <Message>(messages_len); for (int message_index = 0; message_index < messages_len; message_index++) { Message messages_element; messages_element = TL.Parse <Message>(reader); messages.Add(messages_element); } // chats result = reader.ReadUInt32(); // vector#1cb5c415 int chats_len = reader.ReadInt32(); chats = new List <Chat>(chats_len); for (int chat_index = 0; chat_index < chats_len; chat_index++) { Chat chats_element; chats_element = TL.Parse <Chat>(reader); chats.Add(chats_element); } // users result = reader.ReadUInt32(); // vector#1cb5c415 int users_len = reader.ReadInt32(); users = new List <User>(users_len); for (int users_index = 0; users_index < users_len; users_index++) { User users_element; users_element = TL.Parse <User>(reader); users.Add(users_element); } }
private async Task DoSendContact(UserModel user) { if (!(dialogToReturn is DialogModelPlain)) { return; } InputPeer ip = dialogToReturn.InputPeer; InputMedia media = TL.inputMediaContact(user.PhoneNumber, user.FirstName, user.LastName); DialogModelPlain dialog = (DialogModelPlain)dialogToReturn; await dialog.SendMedia(media); }
public ActionResult Index <TD, TL>() where TD : new() where TL : new() { BusinessLayer <T> bl = new BusinessLayer <T>(new CapaNavDocDal()); List <T> mDatas = bl.GetList(); List <TD> mDataDetails = mDatas.Select(d => (TD)d.ToModel(new TD())).ToList(); TL tl = new TL(); typeof(TL).GetProperties()[0].SetValue(tl, mDataDetails); // ReSharper disable once Mvc.ViewNotResolved return(View("Index", tl)); }