Esempio n. 1
0
 protected void UpdateRow(Dictionary <string, object> result, INodePluginWriteContext writectx)
 {
     if (writectx.Row != null)
     {
         foreach (var kvp in result)
         {
             writectx.Row[kvp.Key] = kvp.Value;
         }
     }
 }
 protected abstract object Write(INodePluginWriteContext pw);
        protected override void ExecuteWrite(INodePluginWriteContext pw)
        {
            string state = pw.Row["state"].ToString();

            IIntroContentProvider contentProvider = GetContentProvider(pw);

            if (pw.NodeKey.Equals("harddeletefiles"))
            {
                contentProvider.HardDeleteAll();
                return;
            }

            var       exampleData = pw.Row["example"] as Dictionary <string, object>;
            string    exampleName = exampleData["Id"].ToString();
            IntroItem item        = ConstructIntroItem(exampleData);

            switch (state)
            {
            case "1":
            {
                contentProvider.CreateIntroItem("ForReview", item);
                break;
            }

            case "2":
            {
                if (pw.NodeKey.Equals("approve"))
                {
                    string sectionId = pw.Row["sectionId"].ToString();
                    contentProvider.ApproveExample(sectionId, item);
                }
                else
                {
                    contentProvider.UpdateIntroItem(exampleName, item);
                }

                break;
            }

            case "3":
            {
                contentProvider.DeleteIntroItem(exampleName, item);
                break;
            }

            default:
            {
                throw new Exception("Operation not supported or operation parameter not supplied");
            }
            }

            if (pw.Row.ContainsKey("example"))
            {
                //var exampleData = pw.Row["example"] as Dictionary<string, object>;
                //var exampleSources = exampleData["Sources"] as Dictionary<string, object>;
                //exampleName = exampleData["Id"].ToString();

                //var entries = exampleSources["Entries"] as List<object>;

                //item = new IntroItem
                //{
                //    Id = exampleData["Id"].ToString(),
                //    Caption = exampleData["Caption"].ToString(),
                //    Description = exampleData["Description"].ToString(),
                //    Sources = new Sources(),
                //    LaunchSpec = null
                //};
                //for (int i = 0; i < entries.Count; i++)
                //{
                //    var entrie = entries[i] as Dictionary<string, object>;
                //    item.Sources.Entries.Add(new SourceEntry
                //    {
                //        Content = entrie["Content"].ToString(),
                //        Type = (ESourceType)int.Parse(entrie["Type"].ToString()),
                //        EntryName = entrie["EntryName"].ToString()
                //    });
                //}
            }



            //if (!pw.NodeKey.Equals("harddeletefiles"))
            //{
            //    var exampleData = pw.Row["example"] as Dictionary<string, object>;
            //    var exampleSources = exampleData["Sources"] as Dictionary<string, object>;
            //    string exampleName = exampleData["Id"].ToString();

            //    var entries = exampleSources["Entries"] as List<object>;

            //    IntroItem item = new IntroItem
            //    {
            //        Id = exampleData["Id"].ToString(),
            //        Caption = exampleData["Caption"].ToString(),
            //        Description = exampleData["Description"].ToString(),
            //        Sources = new Sources(),
            //        LaunchSpec = null
            //    };
            //    for (int i = 0; i < entries.Count; i++)
            //    {
            //        var entrie = entries[i] as Dictionary<string, object>;
            //        item.Sources.Entries.Add(new SourceEntry
            //        {
            //            Content = entrie["Content"].ToString(),
            //            Type = (ESourceType)int.Parse(entrie["Type"].ToString()),
            //            EntryName = entrie["EntryName"].ToString()
            //        });
            //    }


            //}
            //else
            //{
            //    contentProvider.HardDeleteAll();
            //}
        }
Esempio n. 4
0
 protected abstract void ExecuteWrite(INodePluginWriteContext pw);