コード例 #1
0
 public static ValispaceAPI Connect(string domain, string username, string password)
 {
     try
     {
         var valispaceApi = new ValispaceAPI(domain, username, password);
         return(valispaceApi);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
ファイル: Login.xaml.cs プロジェクト: valispace/ValispaceSTK
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            var url0 = url_textbox.Text;
            var user = username_textbox.Text;

            if (url0 == "" || user == "" || passwordBox.Password == "")
            {
                MessageBox.Show("A Login field cannot be empty. Please Retry!");
                return;
            }
            var url1     = baseUrl(url0);
            var passHash = Protect(passwordBox.Password);



            valispace = ValispaceAPI.Connect(url1, user, Unprotect(passHash));
            if (valispace.GetAuthenticationResult() != null)
            {
                loggedIn = true;
                Dictionary <string, object> LoginInfo = new Dictionary <string, object>();
                LoginInfo.Add("URL", url0);
                LoginInfo.Add("User", user);
                LoginInfo.Add("Password", passHash);

                projInfoFile.writeInfo("Cred", LoginInfo);
                //string fileName = @"C:\Temp\temp_valicred.txt";
                //// Check if file already exists. If yes, delete it.
                //if (File.Exists(fileName))
                //{
                //    File.Delete(fileName);
                //}

                //// Create a new file
                //using (FileStream fs = File.Create(fileName))
                //{
                //    Byte[] title = new UTF8Encoding(true).GetBytes(url0 + ":" + user + ":" + passHash);
                //    fs.Write(title, 0, title.Length);


                /// CHANGE ALL THIS WHEN DOING WINDOW INTERACTION
                //this.Hide();
                //m_parent.Show();

                //}
                this.Hide();
            }
            else
            {
                MessageBox.Show("Invalid Credentials", "Warning");
                this.Show();
            }
        }
コード例 #3
0
        public ValispaceInstance(string ProjectName, TreeView projectTree)
        {
            //valispace = ValispaceAPI.Connect("https://app.valispace.com", "kuldeep", "valispace.");
            try
            {
                valispace        = WPFLogin.valispace;
                this.projectTree = projectTree;
                if (valispace == null)
                {
                    return;
                }
            }
            catch
            {
                MessageBox.Show("You are not Logged in ! ", "Warning");
            }
            var projects = valispace.getProjects();

            //var p = new List<Project>();
            foreach (var project in projects)
            {
                if ((string)project["name"] == ProjectName)
                {
                    selectedProject      = new Project();
                    selectedProject.Name = (string)project["name"];
                    selectedProject.Id   = (Int64)project["id"];
                    projLoaded           = true;
                    break;
                }
            }
            if (projLoaded)
            {
                loadProjectTree(selectedProject);
            }
            else
            {
                MessageBox.Show("Project with Selected Name doesnt Exist. Please check the project Name entered and try again!");
            }
        }
コード例 #4
0
        public void loadProjectTree(Project project, ValispaceAPI valispace)
        {
            var componentById = new Dictionary <Int64, Dictionary <string, object> >();
            var valiById      = new Dictionary <Int64, Dictionary <string, object> >();
            var roots         = new List <Dictionary <string, object> >();

            Component processDatasetTree(Dictionary <string, object> root)
            {
                var TopItem   = new TreeViewItem();
                var component = new Component()
                {
                    Name  = (string)root["name"],
                    Id    = (Int64)root["id"],
                    Items = new List <object>(),
                };

                TopItem.Header = component.Name;
                Dictionary <string, object> comp_root = valispace.getComponent(component.Id);

                if (comp_root.ContainsKey("valis"))
                {
                    var  valis      = (Newtonsoft.Json.Linq.JArray)comp_root["valis"];
                    bool containsDS = false;
                    if (valis != null)
                    {
                        foreach (var vali in valis)
                        {
                            var valiId   = (Int64)vali;
                            var valiData = valiById[valiId];
                            if ((string)valiData["path"] == "DataSets")
                            {
                                DataSet thisDataSet = new DataSet()
                                {
                                    Name   = (string)valiData["name"],
                                    parent = component,
                                    //dataset_ID = (Int64)valiData["datasets"],
                                    vali_ID = valiId
                                };
                                TreeViewItem itemVali = new TreeViewItem();
                                itemVali.Header = thisDataSet.Name;

                                containsDS = true;
                                TopItem.Items.Add(itemVali);
                                if (!allDataSets.ContainsKey(thisDataSet.Name))
                                {
                                    allDataSets.Add(thisDataSet.Name, thisDataSet);
                                    allDataSetsbyID.Add(thisDataSet.vali_ID, thisDataSet);
                                }
                            }
                        }
                    }
                    if (containsDS)
                    {
                        m_ValiDSTree.Items.Add(TopItem);
                    }
                }

                if (root.ContainsKey("children"))
                {
                    var children = (Newtonsoft.Json.Linq.JArray)root["children"];

                    if (children != null)
                    {
                        foreach (var child in children)
                        {
                            var componentId   = (Int64)child;
                            var componentData = componentById[componentId];

                            component.Items.Add(processDatasetTree(componentData));
                        }
                    }
                }



                return(component);
            }

            var projectComponents = valispace.getComponents(project.Id, project.Name);
            var projectValis      = valispace.getValis(project.Id);

            foreach (var vali in projectValis)
            {
                valiById.Add((Int64)vali["id"], vali);
            }

            var items = new List <Component>();

            foreach (var component in projectComponents)
            {
                if (component["parent"] == null)
                {
                    roots.Add(component);
                }
                else
                {
                    componentById.Add((Int64)component["id"], component);
                }
            }



            foreach (var root in roots)
            {
                items.Add(processDatasetTree(root));
            }

            //valiTree_XAML.Items.Add(items);
            //DataSet_Tree.ItemsSource = items;
            //TreeViewItem item = DataSet_Tree.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem;
            //item.IsExpanded = true;
            //((TreeViewItem)projectTree.Items[0]).IsExpanded = true;
        }
コード例 #5
0
 public ValispaceInstance(ValispaceAPI valiInstance)
 {
     valispace = valiInstance;
 }