Ejemplo n.º 1
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            D2Document   doc        = null;
            D2Repository repository = Global.GetRepository();

            if (String.IsNullOrEmpty(txtName.Text))
            {
                lblError.Visible   = true;
                lblError.Text      = "Name is required";
                lblError.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                lblError.Text    = "";
                lblError.Visible = false;
                if (txtPath.Text.Contains("/"))
                {
                    lblError.Visible = true;
                    lblError.Text    = "Is a path";
                    Folder saveToFolder = repository.GetOrCreateFolderByPath(txtPath.Text);

                    if (!String.IsNullOrEmpty(fileToUpload.FileName))
                    {
                        string trailingPath = Path.GetFileName(fileToUpload.PostedFile.FileName);
                        string fullPath     = Path.Combine(Server.MapPath(" "), trailingPath);
                        fileToUpload.SaveAs(fullPath);
                        FileInfo tmpFile = new FileInfo(fullPath);
                        //doc = repository.ImportNewD2Document(tmpFile, txtName.Text, txtPathOrProfile.Text);
                        D2Configuration d2Config = new D2Configuration();
                        d2Config.StartVersion = Double.Parse(txtStartVersion.Text);
                        doc = repository.ImportNewD2Document(tmpFile, txtName.Text, txtPath.Text, d2Config);
                        doc.SetPropertyValue("object_name", txtName.Text);
                        doc.SetPropertyValue("title", txtTitle.Text);
                        doc.SetPropertyValue("subject", txtSubject.Text);
                        doc.Save();
                        doc = doc.Fetch <D2Document>();
                        lblError.ForeColor = System.Drawing.Color.Green;
                        lblError.Text      = "Saved: \n" + doc.ToString();
                        tmpFile.Delete();
                    }
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = "Is a profile";
                }
            }
        }
Ejemplo n.º 2
0
        private void Temp()
        {
            if (CurrentRepository.isD2Rest())
            {
                /* Get D2 Configs */
                D2Configurations d2configs = CurrentRepository.GetD2Configurations(null);


                /* Get the Search Configurations from D2 Config */
                SearchConfigurations searchConfigs = d2configs.getSearchConfigurations();
                int i = 0;
                for (i = 0; i < searchConfigs.Entries.Count; i++)
                {
                    /* For Each Search configuration, get the entry link */
                    SearchConfigLink scl = searchConfigs.Entries[i];
                    //Console.WriteLine("SearchConfigTitle=" + scl.title + ", SearchConfigId=" + scl.id + " LinkSrc: " + scl.content.Src);
                    /* Ouput SearchConfiguration information for each SearchConfigLink */
                    SearchConfiguration sc = searchConfigs.getSearchConfiguration(scl.content.Src);
                    //Console.WriteLine(sc.ToString());
                }

                /* Get the Profile Configurations from D2 Config */
                ProfileConfigurations profileConfigs = d2configs.getProfileConfigurations();
                i = 0;
                // for (i=0; i < profileConfigs.Entries.Count; i++)
                //{
                /* For each profile configuraton get the entry link */
                ProfileConfigLink pcl = profileConfigs.Entries[i];
                //Console.WriteLine("\n\nProfileConfigTitle=" + pcl.title + ", ProfileConfigId=" + pcl.id + " LinkSrc: " + pcl.content.Src);
                /* Output ProfileConfiguration information for each ProfileConfigLink */
                ProfileConfiguration pc = profileConfigs.getProfileConfiguration(pcl.content.Src);
                //Console.WriteLine(pc.ToString());
                D2Document d2doc = new D2Document();
                d2doc.SetPropertyValue("object_name", "D2-ConfigTst-" + DateTime.Now.Ticks);
                d2doc.SetPropertyValue("primary_bus_owner", "Rest");
                d2doc.SetPropertyValue("template_developers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("comm_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("business_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("compliance_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("brand_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("legal_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("ada_reviewers", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("template_admins", new String[] { "dmadmin" });
                d2doc.SetPropertyValue("form_type", "ACT");
                d2doc.SetPropertyValue("form_subtype", "Alternate Loan Notice");
                d2doc.SetPropertyValue("document_subject", "Automatic payment");
                d2doc.SetPropertyValue("requester", "dmadmin");
                d2doc.SetPropertyValue("r_object_type", "wf_form_template");
                d2doc.SetPropertyValue("r_is_virtual_doc", Convert.ToInt32(true));
                d2doc.SetPropertyValue("import_archive", false);
                d2doc.SetPropertyValue("a_status", "Revise");
                d2doc.SetPropertyValue("merge_needed", true);
                d2doc.SetPropertyValue("system_ver_available", true);
                D2Configuration d2config = new D2Configuration();
                d2config.LifeCycle    = "WF Template Lifecycle";
                d2config.StartVersion = 0.5d;
                // This was an attempt to figure out what the properties_string/properties_xml properties that d2-config has. It was a fail
                // so will have to wait for documentation to update to reflect what these do.
                //d2config.PropertiesString = "title=BLAHBLAHBLAH";
                d2doc.Configuration = d2config;

                GenericOptions importOptions = new GenericOptions();
                importOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile("RestDotNetFramework.docx"));
                d2doc = CurrentRepository.ImportD2DocumentWithContent(d2doc, new FileInfo(@"C:\SamplesToImport\RestDotNetFramework.docx")
                                                                      .OpenRead(), ObjectUtil.getMimeTypeFromFileName("RestDotNetFramework.docx"), importOptions);


                if (d2doc != null)
                {
                    Console.WriteLine("\n\nNew D2Document: \n" + d2doc.ToString());
                }
                else
                {
                    Console.WriteLine("Creation failed!");
                }
                Console.WriteLine("==================================================================================");
                Console.WriteLine("TaskList Basic Info:");
                Feed <D2Task> taskFeed = CurrentRepository.GetD2TaskList();
                List <D2Task> tasks    = ObjectUtil.getFeedAsList(taskFeed);
                int           taskNum  = 0;
                foreach (D2Task task in tasks)
                {
                    taskNum++;
                    Console.WriteLine("TASK #" + taskNum + "-------------------------------------------------");
                    Console.WriteLine("\tTaskSubject: " + task.TaskSubject + " TaskInstructions: " + task.TaskInstructions);
                    Console.WriteLine("\tForward Tasks: ");
                    foreach (String key in task.TaskRequirements.ForwardTasks.Keys)
                    {
                        Console.WriteLine("\t\t" + "TaskName: " + key + " TaskId" + task.TaskRequirements.ForwardTasks[key]);
                    }
                }

                Console.ReadLine();
            }
        }