private async Task <MainEntity> DownloadFromLive(CancellationToken ct) { var liveProvider = LiveProvider; MainEntity res = null; Log.StartTiming("DownloadFromLive"); try { TryAuthoriseLive(liveProvider); if (!liveProvider.IsAuthorised) { return(null); } var serializer = new XmlSerializer(typeof(MainEntity)); using (var stream = await liveProvider.GetFileByName("me/skydrive/files", "MainEntity.xml", ct)) { var entity = (MainEntity)serializer.Deserialize(stream); res = entity; } Log.StopTiming("DownloadFromLive"); return(res); } catch (Exception ex) { Log.LogException(ex); } Log.StopTiming("DownloadFromLive"); return(res); }
public void InstanceEntitiesFromExcelSampleOne() { var mainEntityInstance = new MainEntity(); var helper = new Xls2ObjectHelper(); var appDir = AppDomain.CurrentDomain.BaseDirectory; var assemblyFileName = Path.Combine(appDir, AssemblySampleFolder, sampleAssemblyNAme); var assemblyStream = File.Open(assemblyFileName, FileMode.Open, FileAccess.Read); helper.LoadAssembly(assemblyStream); var excelSampleOneStream = File.Open(Path.Combine(appDir, ExcelSamplesFolder, ExcelsampleOneName), FileMode.Open); var importSettingsFileName = Path.Combine(appDir, ImportSettingsFolder, ExcelSampleOneMainEntitySettingsName); var importSettingsFileStream = File.Open(importSettingsFileName, FileMode.Open, FileAccess.Read); var list = helper.GetObjectsFromExcel(excelSampleOneStream, importSettingsFileStream); var castedList = new List <MainEntity>(); foreach (var entity in list) { var castedEntity = new MainEntity(); castedEntity.MainEntityId = entity.MainEntityId; castedEntity.StringFieldSample = entity.StringFieldSample; castedEntity.DateTimeFieldSample = entity.DateTimeFieldSample; castedList.Add(castedEntity); } excelSampleOneStream.Close(); importSettingsFileStream.Close(); assemblyStream.Close(); Assert.AreEqual(castedList.Count, 3); Assert.AreEqual(castedList[2].StringFieldSample, "you need to load"); }
//[HttpPost] //[Route("PostBid")] //public string Post([FromBody]BidBuyer value) //{ // return SellerModel.UpdateBidStatus(Config, value); //} /// Заглушка для Random, для демонстрации private decimal StubForRandom(MainEntity obj) { decimal retVal = obj.currentPrice; string time = DateTime.Now.ToString("yyyyMMddHHmmss"); if (obj.priceBehavior == "Random") { if (!HttpContext.Session.Keys.Contains(obj.uniqueGuid.ToString())) { HttpContext.Session.SetString(obj.uniqueGuid.ToString(), time + "," + obj.currentPrice.ToString()); } else { var fromSession = HttpContext.Session.GetString(obj.uniqueGuid.ToString()); var strArr = fromSession.Split(","); var lastTime = DateTime.ParseExact(strArr[0], "yyyyMMddHHmmss", CultureInfo.InvariantCulture); var timeSpent = obj.getTimeSpent(lastTime); if (timeSpent < obj.periodDuration) { retVal = Decimal.Parse(strArr[1]); } else { Random rnd1 = new Random(); retVal = rnd1.Next(Decimal.ToInt32(obj.minPrice / obj.stepDown), Decimal.ToInt32(obj.startPrice / obj.stepDown)) * obj.stepDown; HttpContext.Session.SetString(obj.uniqueGuid.ToString(), time + "," + retVal.ToString()); } } } return(retVal); }
private async Task <MainEntity> DownloadDromDropbox(CancellationToken ct) { var dropbox = DropboxProvider; MainEntity res = null; Log.StartTiming("DownloadDromDropbox"); try { TryAuthoriseDropbox(dropbox); if (!dropbox.IsAuthorised) { return(null); } var serializer = new XmlSerializer(typeof(MainEntity)); using (var stream = await dropbox.GetFile("/MainEntity.xml", ct)) { var entity = (MainEntity)serializer.Deserialize(stream); res = entity; } } catch (Exception ex) { Log.LogException(ex); } Log.StopTiming("DownloadDromDropbox"); return(res); }
private async Task <bool> UploadToDropbox(MainEntity entity, CancellationToken ct) { var dropbox = DropboxProvider; var res = false; Log.StartTiming("UploadToDropbox"); try { TryAuthoriseDropbox(dropbox); if (!dropbox.IsAuthorised) { return(res); } var serializer = new XmlSerializer(typeof(MainEntity)); using (var stream = new MemoryStream()) { serializer.Serialize(stream, entity); stream.Position = 0; res = await dropbox.Upload("/", "MainEntity.xml", stream, ct); } } catch (Exception ex) { Log.LogException(ex); } Log.StopTiming("UploadToDropbox"); return(res); }
public static string SaveData(IFormCollection forms, IConfiguration Config, string clientIP) { var conStr = Config.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; string uniqueGuid; MainEntity mainEntity; if (forms["inSHidGuid"].ToString().Trim() != string.Empty) { uniqueGuid = forms["inSHidGuid"].ToString().Trim(); mainEntity = MainEntity.Init(forms, clientIP, uniqueGuid, "UPDATE"); } else { uniqueGuid = GetGuid(Config, clientIP); mainEntity = MainEntity.Init(forms, clientIP, uniqueGuid, "CREATE"); } MainEntityRepository mainEntityRepository = new MainEntityRepository(mainEntity); try { using (SqlConnection connection = new SqlConnection(conStr)) { mainEntityRepository.PerformSQLOperation(connection); } } catch (Exception e) { //Logger.SaveErrToLog(e.Message, Config, clientIP); } return(uniqueGuid); }
private async Task <bool> UploadToLive(MainEntity entity, CancellationToken ct) { var liveProvider = LiveProvider; var res = false; Log.StartTiming("UploadToLive"); try { TryAuthoriseLive(liveProvider); if (!liveProvider.IsAuthorised) { return(res); } var serializer = new XmlSerializer(typeof(MainEntity)); using (var stream = new MemoryStream()) { serializer.Serialize(stream, entity); stream.Position = 0; res = await liveProvider.Upload("", "MainEntity.xml", stream, ct) != null; } } catch (Exception ex) { Log.LogException(ex); } Log.StopTiming("UploadToLive"); return(res); }
public Main() { InitializeComponent(); mainControl = new MainControl(this); mainEntity = new MainEntity(); SetDragEvent(tb_file_path, tb_apktool, tb_package_name, tb_loading_path, tb_icon_path, tb_signer_path, tb_channel); InitDataShow(); }
private async Task ExecuteImportExpressions() { Log.StartTiming(); try { if (SyncWithDropboxEnabled && SyncWithLiveEnabled) { WindowService.ShowMessage(Msg.CannotSyncFromTwoSourcesAtTheSameTime); return; } var cts = GetTokenSource(ImportExportGroupName); MainEntity entity = null; if (SyncWithDropboxEnabled) { entity = await DownloadDromDropbox(cts.Token); } else if (SyncWithLiveEnabled) { entity = await DownloadFromLive(cts.Token); } else { using (var o = new OpenFileDialog()) { var res = o.ShowDialog(); if (res == DialogResult.OK) { Log.StartTiming("ImportFromFile"); entity = Persister.ImportFromFile(o.FileName); Log.StopTiming("ImportFromFile"); } } } if (entity != null) { Merge(entity); RefreshAfterMerge(); } else { WindowService.ShowMessage(Msg.ImportFailed); } } catch (Exception ex) { WindowService.ShowError(ex); } finally { RefreshCommands(); } Log.StopTiming(); }
private void BeginAutoHookCmdExecute(object obj) { if (m_mainEntity != null) { return; } m_mainEntity = new MainEntity(Account, Password); m_mainEntity.Start(m_config.ProgramPath); }
public void ValidateBlankMainEntitySettingsCreation() { var instance = new MainEntity(); var helper = new Xls2ObjectHelper(); string blankMainEntityImportSettings = helper.CreateImportSettingsJsonByClass(instance, 2, null); var appDir = AppDomain.CurrentDomain.BaseDirectory; var blankMainEntityImportSettingsFileContent = File.ReadAllText(Path.Combine(appDir, "ImportSettingsFiles", "BlankMainEntityJsonSettingsSample.json")); Assert.AreEqual(blankMainEntityImportSettingsFileContent, blankMainEntityImportSettings); }
public static List <MainEntity> PostUpdatePrices(SqlConnection connection, string[] arrGuids) { List <MainEntity> retList = new List <MainEntity>(); foreach (var elem in arrGuids) { MainEntity item = connection.Query <MainEntity>("[dbo].[PostUpdatePrice]", new { guid = elem }, commandType: CommandType.StoredProcedure).FirstOrDefault(); retList.Add(item); } return(retList); }
public void Start() { m_accountInfo = MainAccountInfo.LoadAccount(m_mainFile); if (!File.Exists(m_mainFile)) { m_accountInfo.Save(); } m_mainEntity = new MainEntity(m_accountInfo); MainTaskMgr.Instance.InitEntityTasks(m_mainEntity); m_mainEntity.DescriptionChanged += MainEntityOnDescriptionChanged; m_mainEntity.Start(); foreach (var t in WxHelper.GetEnumValues <WlySwitchType>()) { var info = m_accountInfo.GetSwitchInfo(t); var wrapper = new WlyTaskSwitchWrapper(info); wrapper.Changed += WrapperOnChanged; Switches.Add(wrapper); } // 主账号监测 m_cancellationTokenSource = new CancellationTokenSource(); var token = m_cancellationTokenSource.Token; Task.Run(() => { while (!token.IsCancellationRequested) { try { Thread.Sleep(TimeSpan.FromMinutes(1)); if (!m_mainEntity.Run) { WxLog.Debug($"WlyAutoVM.Start 对主账号进行重置 <{DateTime.Now}>"); m_mainEntity.Stop(); m_mainEntity.DescriptionChanged -= MainEntityOnDescriptionChanged; MainEntity = new MainEntity(m_accountInfo); MainTaskMgr.Instance.InitEntityTasks(m_mainEntity); m_mainEntity.DescriptionChanged += MainEntityOnDescriptionChanged; m_mainEntity.Start(); } } catch (Exception ex) { WxLog.Error($"WlyAutoVM.Start Error <{ex}>"); } } WxLog.Debug($"WlyAutoVM.Start Stop On <{ResetTime}>"); }, token); //StartSubCmdExecute(this); }
public void Given() { _testRound = Guid.NewGuid(); _data = new MainEntity(_testRound); // Please read SecondaryEntity Equals & GetHashCode. var secondaries = Enumerable.Range(0, 100).Select((i) => new SecondaryEntity($"Prop A {i}", $"Prop B {i}", $"Prop C {i}")); var duplicatedSecondaries = Enumerable.Range(0, 100).Select((i) => new SecondaryEntity($"Prop A {i}", $"Prop B {i}", $"Prop C {i}")); ((List <SecondaryEntity>)_data.Secondaries).AddRange(secondaries); ((List <SecondaryEntity>)_data.Secondaries).AddRange(duplicatedSecondaries); }
private void ProvideContextNamesComp( MainEntity ent ) { var t = ent.iNamedTypeSymbol.Value; var contextNames = t.GetContextNames( ); if ( contextNames.Count == 0 ) { contextNames.Add( "Undefined" ); return; } ent.AddContextNamesComp( contextNames ); }
public int Merge(MainEntity toMerge, MergerConfiguration conf) { toMerge.NotNull("mainEntity"); var oldExpressions = _dataAccess.GetAllExpressions(); if (conf.ImportStatisticsForOld) { UpdateStatistics(toMerge.Expressions, oldExpressions); } MergeExpressionsWithUnknownTranslations(toMerge.Expressions, oldExpressions, conf); return(MergeUnknownExpressions(toMerge.Expressions, oldExpressions, conf)); }
private void ProvideComp( MainEntity ent ) { var t = ent.iNamedTypeSymbol.Value; if ( t.Implements( typeof( IComponent ) ) ) { var fullName = String.IsNullOrEmpty( t.ContainingNamespace.Name ) ? t.Name : t.ContainingNamespace.Name + "." + t.Name; ent.AddComp( t.Name, fullName ); ent.isAlreadyImplementedComp = true; } else { ent.AddNonIComp( t.Name, t.ContainingNamespace.Name + "." + t.Name ); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="Rest.ValidationException"> /// Thrown if validation fails /// </exception> public override void Validate() { base.Validate(); if (About != null) { foreach (var element in About) { if (element != null) { element.Validate(); } } } if (Mentions != null) { foreach (var element1 in Mentions) { if (element1 != null) { element1.Validate(); } } } if (Provider != null) { foreach (var element2 in Provider) { if (element2 != null) { element2.Validate(); } } } if (Creator != null) { Creator.Validate(); } if (MainEntity != null) { MainEntity.Validate(); } if (CopyrightHolder != null) { CopyrightHolder.Validate(); } }
private void ProvideEventComp( MainEntity ent ) { var type = ent.iNamedTypeSymbol.Value; var eventInfos = type.GetAttributes( ) .Where( attr => attr.AttributeClass.ToString( ) == typeof( EventAttribute ).FullName ) .Select( attr => new EventInfo( eventTarget : (EventTarget)attr.ConstructorArguments[0].Value, eventType : (EventType)attr.ConstructorArguments[1].Value, priority : (Int32)attr.ConstructorArguments[2].Value ) ) .ToList( ); if ( eventInfos.Count <= 0 ) { return; } ent.AddEventComp( eventInfos ); CodeGeneratorExtentions.ProvideEventCompNewEnts( _contexts, ent ); }
//主角模型加载 void CreateEntity(int heroId) { Debuger.LogError("CreateEntity 主角模型"); HeroInfo heroInfo = InfoMgr <HeroInfo> .Instance.GetInfo(heroId); //GameObject prefab = ResourcesMgr.Instance.LoadResource<GameObject>(ResourceType.RESOURCE_ENTITY, heroInfo.model); //if (null == prefab) //{ // Debuger.LogError("角色模型不存在Id:" + heroId); // return; //} GameObject go = ResourcesMgr.Instance.Spawner(heroInfo.model, ResourceType.RESOURCE_ENTITY, transform);// ResourcesMgr.Instance.Instantiate(prefab); if (null == go) { Debuger.LogError("角色模型不存在Id:" + heroId); return; } MainEntity.InitCharactor(go); MainEntity.InitEntityAttribute(heroInfo); }
protected internal override void PreSaving(ref bool graphModified) { base.PreSaving(ref graphModified); if (Corrupt) { var integrity = MainEntity.IdentifiableIntegrityCheckBase(); // So, no corruption allowed if (integrity == null) { this.Corrupt = false; if (!MainEntity.IsNew) { Corruption.OnCorruptionRemoved(MainEntity); } } else if (MainEntity.IsNew) { Corruption.OnSaveCorrupted(MainEntity, integrity); } } }
protected internal override void PreSaving(PreSavingContext ctx) { base.PreSaving(ctx); if (Corrupt) { var integrity = MainEntity.EntityIntegrityCheckBase(); // So, no corruption allowed if (integrity == null) { this.Corrupt = false; if (!MainEntity.IsNew) { Corruption.OnCorruptionRemoved(MainEntity); } } else if (MainEntity.IsNew) { Corruption.OnSaveCorrupted(MainEntity, integrity); } } }
/** * 反编译 */ public void ExecuteProcess(MainEntity mainEntity) { this.mainEntity = mainEntity; processUtil = new ProcessUtil(this); processUtil.SetMainEntity(mainEntity); if (CommonUtil.IsEmpty(mainEntity.SignerPath)) { GetAliasEnd(null); } else { if (CommonUtil.IsEmpty(mainEntity.SignerPassword)) { MessageBox.Show("签名文件密码为空"); } else { processUtil.GetAlisa(); } } }
private void Merge(MainEntity source, bool inbackground = true) { Log.StartTiming("Merge"); var conf = new MergerConfiguration { ImportCreationDate = ImportCreationDate, ImportRecentlyUsedDate = ImportRecentlyUsedDate, ImportDefinedDate = ImportDefinedDate, ImportStatisticsForNew = ImportStatisticsForNew, ImportStatisticsForOld = ImportStatisticsForOld }; if (inbackground) { WindowService.DoBackgroundTask( () => Merger.Merge(source, conf)); } else { Merger.Merge(source, conf); } Log.StopTiming("Merge"); }
public MainEntityRepository(MainEntity inpMainEntity) { mainEntity = inpMainEntity; }
public static MainEntity PostBigPhoto(SqlConnection connection, string guid) { MainEntity item = connection.Query <MainEntity>("PostBigPhoto", new { guid = guid }, commandType: CommandType.StoredProcedure).FirstOrDefault(); return(item); }
public static MainEntity GetItemDetail(SqlConnection connection, string guid) { MainEntity item = connection.Query <MainEntity>("GetItemDetail", new { guid = guid }, commandType: CommandType.StoredProcedure).FirstOrDefault(); return(item); }
public static MainEntity GetItem(SqlConnection connection, string guid) { MainEntity res = connection.Query <MainEntity>("[dbo].[GetMainEntityItem]", new { guid = guid }, commandType: CommandType.StoredProcedure).FirstOrDefault(); return(res); }
public XmlUtil(IXmlCallback xmlCallback, MainEntity mainEntity) { this.xmlCallback = xmlCallback; this.mainEntity = mainEntity; }
public void do_not_blow_up() { var entityToStore = new MainEntity { Entity1 = new ChildEntity1 { StringValues = new List <string> { "item1", "item2" } }, Entity2 = new ChildEntity2 { InnerEntities = new List <InnerEntity> { new InnerEntity { MyEnum = SomeEnums.TestEnum1 }, new InnerEntity { MyEnum = SomeEnums.TestEnum2 }, new InnerEntity { MyEnum = SomeEnums.TestEnum3 } } } }; using (var session = theStore.LightweightSession()) { //first store the item in the database session.Store(entityToStore); //now try to get the data back QueryStatistics stats; /*------------------------------------------------------------------*/ //getting an Exception while trying to execute this query var entity1 = session.Query <MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity1.StringValues.Any()); //Marten.MartenCommandException: 'Marten Command Failure: //select d.data, d.id, d.mt_version, count(1) OVER() as total_rows from public.mt_doc_mainentity as d where JSONB_ARRAY_LENGTH(COALESCE(case when data->>'Entity1'->'StringValues' is not null then data->'Entity1'->'StringValues' else '[]' end)) > 0 LIMIT 1 //42883: operator does not exist: text -> unknown' /*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/ //same issue here as well var entity2 = session.Query <MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity2.InnerEntities.Any()); //Marten.MartenCommandException: 'Marten Command Failure: //select d.data, d.id, d.mt_version, count(1) OVER() as total_rows from public.mt_doc_mainentity as d where JSONB_ARRAY_LENGTH(COALESCE(case when data->>'Entity2'->'InnerEntities' is not null then data->'Entity2'->'InnerEntities' else '[]' end)) > 0 LIMIT 1 //42883: operator does not exist: text -> unknown' /*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/ //and this two fail as well //var entity3 = session.Query<MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity1.StringValues.Any(n => n == "item1")); var entity3 = session.Query <MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity1.StringValues.Contains("item1")); //System.NotSupportedException: 'Specified method is not supported.' var entity4 = session.Query <MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity2.InnerEntities.Any(n => n.MyEnum == SomeEnums.TestEnum1)); //System.NotImplementedException: 'The method or operation is not implemented.' /*------------------------------------------------------------------*/ } }