コード例 #1
0
ファイル: Connection.cs プロジェクト: daveh551/web-xforge
        public IDocument <T> Get <T>(string id) where T : IIdentifiable
        {
            DocConfig docConfig = _realtimeService.GetDocConfig <T>();
            object    doc       = _documents.GetOrAdd((docConfig.CollectionName, id), key =>
            {
                string otTypeName = docConfig.OTTypeName;
                return(new Document <T>(_realtimeService.Server, _handle, otTypeName, docConfig.CollectionName, id));
            });

            return((Document <T>)doc);
        }
コード例 #2
0
        public IDocument <T> Get <T>(string id) where T : IIdentifiable
        {
            DocConfig docConfig = _realtimeService.GetDocConfig <T>();

            if (_documents.TryGetValue((docConfig.CollectionName, id), out object docObj))
            {
                return((IDocument <T>)docObj);
            }

            MemoryRepository <T> repo = _realtimeService.GetRepository <T>();
            IDocument <T>        doc  = new MemoryDocument <T>(repo, docConfig.OTTypeName, docConfig.CollectionName, id);

            _documents[(docConfig.CollectionName, id)] = doc;
コード例 #3
0
    public static DocConfig LoadFromString()
    {
        var config = new DocConfig();

        config.Parts = new List <DocPart>();
        var part1 = new DocPart
        {
            Title   = "chapter1",
            Checked = checkBox1.Checked
        };

        config.Parts.Add(part1);

        var part2 = new DocPart
        {
            Title   = "chapter2",
            Checked = checkBox2.Checked
        };

        config.Parts.Add(part2);

        var configString = config.SaveToString();

        File.WriteAllText(@"d:\temp\test.json", configString);

        configString = File.ReadAllText(@"d:\temp\test.json");

        var ms         = new MemoryStream(Encoding.UTF8.GetBytes(configString));
        var serializer = new DataContractJsonSerializer(typeof(DocConfig));

        config = (DocConfig)serializer.ReadObject(ms);

        foreach (var part in config.Parts)
        {
            if (part.Title == "chapter1")
            {
                chekbox1.Checked = part.Checked;
                Debug.WriteLine("chapter1" + part.Checked);
            }
            if (part.Title == "chapter2")
            {
                checkbox2.Checked = part.Checked;
                Debug.WriteLine("chapter2" + part.Checked);
            }
        }

        return(config);
    }
コード例 #4
0
        public static int Main()
        {
            List <DocPart> Parts = new List <DocPart>();
            var            doc   = new DocConfig();

            doc.Description = "bla bla";
            doc.Parts       = new List <DocPart>();
            doc.Parts.Add(new DocPart {
                Title = "aaa", TexLine = @"\include{aaa.tex}"
            });
            doc.Parts.Add(new DocPart {
                Title = "bbb ", TexLine = @"\include{bbb.tex}"
            });
            foreach (DocPart part in doc.Parts)
            {
                Console.WriteLine(part.Title);
            }
            Console.ReadKey();
            return(-1);
        }
コード例 #5
0
 public NoTheReorderingWidget(DocConfig config)
 {
     this.config = config;
     this.Build();
 }
コード例 #6
0
 public AcronymsPanelWidget(DocConfig config)
 {
     this.Build();
     this.config = config;
 }
コード例 #7
0
//		DocConfig config;
		
		public AcronymsPanelWidget (DocConfig config)
		{
			this.Build ();
//			this.config = config;
		}
コード例 #8
0
		public OptionsPanelWidget (DocConfig config)
		{
			this.config = config;
			this.Build ();
		}
コード例 #9
0
//		DocConfig config;
		
		public RulesPanelWidget (DocConfig config)
		{
//			this.config = config;
			this.Build ();
		}
コード例 #10
0
 public RulesPanelWidget(DocConfig config)
 {
     this.config = config;
     this.Build();
 }
コード例 #11
0
        public string GetCollectionName <T>() where T : IIdentifiable
        {
            DocConfig docConfig = GetDocConfig <T>();

            return(docConfig.CollectionName);
        }
コード例 #12
0
		public NoTheReorderingWidget (DocConfig config)
		{
			this.config = config;
			this.Build ();
		}
コード例 #13
0
 public void AddRepository <T>(string collectionName, string otTypeName, MemoryRepository <T> repo)
     where T : IIdentifiable
 {
     _repos[typeof(T)]      = repo;
     _docConfigs[typeof(T)] = new DocConfig(collectionName, typeof(T), otTypeName);
 }
コード例 #14
0
 private void AddDocConfig(DocConfig docConfig)
 {
     _docConfigs[docConfig.Type] = docConfig;
 }
コード例 #15
0
 public OptionsPanelWidget(DocConfig config)
 {
     this.config = config;
     this.Build();
 }
コード例 #16
0
ファイル: ValidateEmpty.cs プロジェクト: guangxb/learn
 /// <summary>
 /// 验证族实例
 /// </summary>
 /// <param name="sourcedoc"></param>
 /// <param name="context"></param>
 /// <param name="std"></param>
 /// <param name="GetRelations"></param>
 /// <returns></returns>
 static bool ValidateConfigParts(DocStruct sourcedoc, ValidateContext context, DocConfig std, Func <ChildStruct, IList> GetRelations)
 {
     if (std != null)
     {
         sourcedoc.ConfigId = std.ConfigID;
         if (!string.IsNullOrEmpty(std.MatVerId))
         {
             sourcedoc.MaterialVerId = std.MatVerId;
         }
         BOMHelp.Write(context.CurScopeProperty, "__STD_OLD_MaterialVerId", std.MatVerId);
         foreach (var current in sourcedoc.ParentRelation.Where(p => p.ParentNode != null))
         {
             DocStruct parent = current.ParentNode;
             IEnumerable <ObjectRelation> source = GetRelations(current).Cast <ObjectRelation>();
             if (!source.Any <ObjectRelation>())
             {
                 if (!ValidatorHelp.CheckPCRelation(current))
                 {
                     bool result = false;
                     return(result);
                 }
                 sourcedoc.IsBorrow          = true;
                 current.RelationOperateType = RelationOperateType.AddRelation;
             }
             else
             {
                 if (parent.IsBorrow)
                 {
                     sourcedoc.IsBorrow = true;
                 }
                 else
                 {
                     ObjectRelation objectRelation = source.FirstOrDefault((ObjectRelation p) => (string.IsNullOrEmpty(p.ParentConfigID) || p.ParentConfigID == parent.ConfigId) && BOMHelp.IsEquals(p.ConfigID, std.ConfigID));
                     if (objectRelation != null)
                     {
                         current.RelationId = objectRelation.RelationId;
                         bool flag = current.Count == current.HiddenCount;
                         if (objectRelation.IsHidden != flag || !BOMHelp.Contains(parent.OperateType, EntityOperateType.NotCheckOut))
                         {
                             current.RelationOperateType = RelationOperateType.ModifyRelation;
                         }
                     }
                     else
                     {
                         current.RelationOperateType = RelationOperateType.AddRelation;
                     }
                 }
             }
         }
     }
     else if (!ValidateCreoConfig.IsZuBiao(sourcedoc)) //没有到如果该配置 同时不是族表实例
     {
         foreach (var item in sourcedoc.ParentRelation.Where(p => p.ParentNode != null))
         {
             if (!ValidatorHelp.CheckPCRelation(item))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #17
0
ファイル: ValidateEmpty.cs プロジェクト: guangxb/learn
        public override bool Validate(ValidateContext context)
        {
            DocStruct doc = context.ValidateObject as DocStruct;

            if (doc != null && doc.IsConfigPart)
            {
                string text = "借用";
                if (BOMHelp.Contains(doc.OperateType, EntityOperateType.NotCheckOut))
                {
                    text = "未检出";
                }
                DocumentVersion documentVersion = BOMHelp.GetOValueFromDictionary(context.CurScopeProperty, _.CURVALIDATEDOCUMENT) as DocumentVersion;
                DocumentCopy    documentCopy    = BOMHelp.GetOValueFromDictionary(context.CurScopeProperty, _.CURVALIDATEDOCCOPY) as DocumentCopy;
                if (documentVersion != null) //文档已经存在
                {
                    List <DocStruct>  list  = doc.DataView.DocList.ToList <DocStruct>();
                    IList <DocConfig> list2 = BOMHelp.GetOValueFromDictionary(context.ExtendProperty, documentVersion.VerId) as IList <DocConfig>;
                    if (list2 == null)
                    {
                        list2 = this.docconfigManager.GetStandardPartsConfigByDVerId(documentVersion.VerId);
                        BOMHelp.Write(context.ExtendProperty, documentVersion.VerId, list2);
                    }
                    if (doc.IsBorrow || BOMHelp.Contains(doc.OperateType, EntityOperateType.NotCheckOut))
                    {
                        DocConfig docConfig = list2.FirstOrDefault((DocConfig p) => p.ConfigName == doc.ConfigName);
                        if (docConfig == null) //查找索引相同的配置
                        {
                            if (list2.All((DocConfig p) => string.IsNullOrEmpty(p.ConfigName)))
                            {
                                docConfig = list2.FirstOrDefault((DocConfig p) => BOMHelp.IndexIsEqualsG <DocConfig>(p, doc, this.IndexFields));
                            }
                        }
                        if (docConfig == null) //未找到的配置
                        {
                            if (IsZuBiao(doc))
                            {
                                doc.CFG_OperateType = EntityOperateType.CreateNewVer;
                                ValidatorHelp.SetSelfRelationType(doc, RelationOperateType.AddRelation);
                            }
                            else
                            {
                                if (list2.Count < list.Count)
                                {
                                    doc.SetDocStateL(false, "red", "{0}:文档配置不允许新增", text);
                                }
                                else
                                {
                                    doc.SetDocStateL(false, "red", "{0}:文档配置名称被修改", text);
                                }
                                return(false);
                            }
                        }
                        else
                        {
                            ValidatorHelp.ValiedateDocChanage <DocConfig>(doc, doc, docConfig, this.IndexFields, documentCopy.FileMD5, text, false);
                            if (string.IsNullOrEmpty(docConfig.ConfigName))
                            {
                                doc.CFG_OperateType = EntityOperateType.UpdateVer;
                            }
                        }
                    }
                    else
                    {
                        DocConfig docConfig2 = list2.FirstOrDefault((DocConfig p) => p.ConfigName == doc.ConfigName);
                        if (docConfig2 == null)
                        {
                            if (list2.All((DocConfig p) => string.IsNullOrEmpty(p.ConfigName)))
                            {
                                docConfig2 = list2.FirstOrDefault((DocConfig p) => BOMHelp.IndexIsEqualsG <DocConfig>(p, doc, this.IndexFields));
                            }
                        }
                        if (docConfig2 != null)
                        {
                            DocStruct currentData = doc.DataView.GetCurrentData();
                            if (BOMHelp.PropertyIsEqualsG <DocConfig>(docConfig2, doc, this.IndexFields, false))
                            {
                                doc.CFG_OperateType = (string.IsNullOrEmpty(docConfig2.ConfigName) ? EntityOperateType.UpdateVer : EntityOperateType.JustCheckIn);
                                doc.OperateType     = EntityOperateType.JustCheckIn;
                                if (BOMHelp.Contains(currentData.OperateType, EntityOperateType.None))
                                {
                                    currentData.OperateType = EntityOperateType.JustCheckIn;
                                }
                            }
                            else
                            {
                                if (!BOMHelp.IndexIsEqualsG <DocConfig>(docConfig2, doc, this.IndexFields))
                                {
                                    doc.SetDocStateL(false, "red", "文档的索引已经修改");
                                    return(false);
                                }
                                doc.OperateType     = EntityOperateType.UpdateVer;
                                doc.CFG_OperateType = EntityOperateType.UpdateVer;
                                if (!BOMHelp.Contains(currentData.OperateType, EntityOperateType.UpdateVer))
                                {
                                    currentData.OperateType = EntityOperateType.UpdateVer;
                                }
                            }
                        }
                        else
                        {
                            doc.CFG_OperateType = EntityOperateType.CreateNewVer;
                            ValidatorHelp.SetSelfRelationType(doc, RelationOperateType.AddRelation);
                        }
                    }
                }
                else
                {
                    doc.CFG_OperateType = doc.OperateType;
                }
            }
            return(true);
        }
コード例 #18
0
//		DocConfig config;
		
		public ExpansionsPanelWidget (DocConfig config)
		{
//			this.config = config;
			this.Build ();
		}
コード例 #19
0
//		DocConfig config;

        public ExpansionsPanelWidget(DocConfig config)
        {
//			this.config = config;
            this.Build();
        }