コード例 #1
0
ファイル: RecordManager.cs プロジェクト: rabiribi/OrbitII
    void ConfirmNewRecord()
    {
        Debug.Assert(newRecordWindow != null, "没有newRecordWindow");
        Text[] allTexts   = newRecordWindow.GetComponentsInChildren <Text>();
        Text   recordName = null;
        Text   seedText   = null;

        foreach (Text t in allTexts)
        {
            if (t.gameObject.name.Equals("NameText"))
            {
                recordName = t;
            }
            else if (t.gameObject.name.Equals("SeedText"))
            {
                seedText = t;
            }
        }
        Debug.Assert(recordName != null, "没有找到Name");
        Debug.Assert(seedText != null, "没有找到Seed");

        Record newReco = new Record();

        if (newReco.SetName(recordName.text) != null)
        {
            // 地图种子为
            string seedString = seedText.text + "";
            if (seedString.Equals(""))
            {
                seedString = System.DateTime.Now.ToString();
            }
            newReco.seed = seedString.GetHashCode();
            UIManager.Instance.CloseModel();
            newReco.SaveInfo();
            SaveManager.Instance.EnterRecord(newReco);
            return;
        }
        else
        {
            newRecordWindow.transform.Find("WarningText").gameObject.SetActive(true);
        }
    }
コード例 #2
0
    /// <summary>
    /// Saves contents of the UI fields into the <see cref="Record"/>.
    /// </summary>
    ///
    protected override void OnSaveData()
    {
        Record.SetName(this.companyName.TrimmedText);

        Record.SetVatNo(this.vatNo.TrimmedText);

        Record.Address  = this.address.TrimmedText;
        Record.PostCode = this.postCode.TrimmedText;
        Record.City     = this.city.TrimmedText;
        Record.Country  = this.country.TrimmedText;
        Record.Phone    = this.phone.TrimmedText;
        Record.HomePage = this.homePage.TrimmedText;
        Record.EMail    = this.email.TrimmedText;

        base.OnSaveData();

        // Reload saved values and clean ContentsChanged for all fields
        //
        OnLoadData();

        // Update application title
        //
        MainForm.UpdateTitle();
    }
コード例 #3
0
        public async Task <string> GroupAsync(string[] items)
        {
            if (items == null || items.Length < 0)
            {
                throw new ArgumentException();
            }


            //以前に設定されていたグループ
            var oldGroupsList = new List <string[]>();

            //対象に含まれているグループのメンバー
            var groupMembersList = new List <string[]>();

            //対象に含まれているグループ
            string[] relatedGroups;


            using (var connection = await this.Table.Parent.ConnectAsync())
            {
                var relatedGroupsList = new List <string[]>();

                foreach (var ids in items.Buffer(128))
                {
                    var param = new Tuple <string[]>(ids.ToArray());

                    //渡されたコレクションから設定されているグループを列挙
                    var r = await this.Table.QueryAsync <string>(connection, this.recordSql, param);

                    //対象に含まれているグループを列挙
                    var g = await this.Table.QueryAsync <string>(connection, this.groupSql, param);

                    oldGroupsList.Add(r.ToArray());
                    relatedGroupsList.Add(g.ToArray());
                }

                //対象に含まれているグループ
                relatedGroups = relatedGroupsList.SelectMany(x => x).Distinct().ToArray();

                //グループメンバーを取得
                foreach (var g in relatedGroups)
                {
                    var filter = this.Library.GroupQuery.GetGroupFilterString(g);

                    var members = await this.Table
                                  .AsQueryable(connection)
                                  .Where(filter)
                                  .Select <string>(nameof(Record.Id))
                                  .Distinct()
                                  .ToArrayAsync();

                    groupMembersList.Add(members);
                }
            }

            //以前に設定されていたグループ
            var oldGroups = oldGroupsList.SelectMany(x => x).Distinct().ToArray();

            //対象に含まれているグループのメンバー
            var groupMembers = groupMembersList.SelectMany(x => x).Distinct().ToArray();

            //関係するすべてのグループ
            var uniqueGroups = oldGroups
                               .Union(relatedGroups)
                               .Where(x => !string.IsNullOrWhiteSpace(x))
                               .ToArray();



            string groupKey = null;
            Record group    = null;

            if (uniqueGroups.Length == 1)
            {
                //関係するグループが一種類ならそれが新しいグループ
                groupKey = uniqueGroups[0];
            }


            using (var connection = this.Table.Parent.ConnectAsThreadSafe())
            {
                var isNewGroupGenerated = false;

                group = (groupKey != null)
                    ? await this.Table.GetRecordFromKeyAsync(connection.Value, groupKey) : null;


                if (group == null || !group.IsGroup)
                {
                    //新しいグループを作る
                    groupKey = await this.GenerateNewGroupKeyAsync(connection.Value);

                    group = Record.GenerateAsGroup(groupKey);
                    group.SetName(this.GenerateGroupName(connection.Value));
                    isNewGroupGenerated = true;
                }


                //新しいグループを設定
                await this.SetGroupAsync(connection.Value, groupKey, items.Union(groupMembers));

                if (isNewGroupGenerated)
                {
                    var filter = this.Library.GroupQuery.GetGroupFilterString(groupKey);

                    var leader = await this.Table.AsQueryable(connection.Value)
                                 .Where(filter)
                                 .OrderBy(FileProperty.FileName.ToSort(false))
                                 .FirstAsync();

                    //リーダーのタグを全て確認
                    //グループメンバーで同じものを持っていないレコードが一つもない場合はグループにもタグをつける
                    foreach (var tag in leader.TagSet.Read())
                    {
                        var f = DatabaseExpression.And
                                    (filter, FileProperty.ContainsTag.ToSearch(tag, CompareMode.NotEqual));
                        var woTag = await this.Table.CountAsync(connection.Value, f);

                        if (woTag == 0)
                        {
                            group.TagSet.Add(tag);
                        }
                    }

                    //グループの評価はメンバーの中で最大のもの
                    var rating = await this.Table.MaxAsync <int>
                                     (connection.Value, nameof(Record.Rating), filter);

                    group.Rating = rating;

                    //リーダーを設定
                    group.SetGroupLeader(leader);
                }

                //データベースに保存
                using (var transaction = connection.Value.BeginTransaction())
                {
                    try
                    {
                        await this.Table.ReplaceAsync(group, connection.Value, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                }

                //グループの情報を更新
                await this.RefreshGroupPropertiesAsync
                    (connection.Value, uniqueGroups.Append(group.Id).Distinct().ToArray());
            }

            return(groupKey);
        }
コード例 #4
0
ファイル: PascalParser.cs プロジェクト: BooMWax/ifmo
	public Record recordDef()
	{
		EnterRule_recordDef();
		EnterRule("recordDef", 5);
		TraceIn("recordDef", 5);
		Record rec = default(Record);


		IToken identifier8 = default(IToken);
		List<Variable> recordVariableList9 = default(List<Variable>);


				rec = new Record();
			
		try { DebugEnterRule(GrammarFileName, "recordDef");
		DebugLocation(87, 5);
		try
		{
			// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:92:6: ( TYPE identifier EQUAL RECORD recordVariableList END SEMI )
			DebugEnterAlt(1);
			// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:92:8: TYPE identifier EQUAL RECORD recordVariableList END SEMI
			{
			DebugLocation(92, 8);
			Match(input,TYPE,Follow._TYPE_in_recordDef308); 
			DebugLocation(92, 13);
			PushFollow(Follow._identifier_in_recordDef310);
			identifier8=identifier();
			PopFollow();

			DebugLocation(92, 24);
			 rec.SetName(identifier8); 
			DebugLocation(92, 58);
			Match(input,EQUAL,Follow._EQUAL_in_recordDef314); 
			DebugLocation(92, 64);
			Match(input,RECORD,Follow._RECORD_in_recordDef316); 
			DebugLocation(93, 7);
			PushFollow(Follow._recordVariableList_in_recordDef324);
			recordVariableList9=recordVariableList();
			PopFollow();

			DebugLocation(94, 7);

			    			foreach(var child in recordVariableList9)
			    			{
			    				rec.AddChild(child);
			    			}
			    		
			DebugLocation(100, 7);
			Match(input,END,Follow._END_in_recordDef340); 
			DebugLocation(100, 11);
			Match(input,SEMI,Follow._SEMI_in_recordDef342); 

			}

		}

			catch (RecognitionException e)
			{
		        	throw e;
		    	}

		finally
		{
			TraceOut("recordDef", 5);
			LeaveRule("recordDef", 5);
			LeaveRule_recordDef();
		}
		DebugLocation(101, 5);
		} finally { DebugExitRule(GrammarFileName, "recordDef"); }
		return rec;

	}