public void Execute()
        {
            logger.Info("Extract Users List in progress...");
            var         projectCollections = CatalogNodeBrowsingHelper.GetProjectCollections(configurationServer.CatalogNode);
            List <User> userList           = IdentityServiceManagementHelper.GetAllIdentities(configurationServer, projectCollections).ToList();

            // Now get the "ou" attribute from the Active Directory (so as to gets a user's Service)
            if (this.extractOUOption)
            {
                logger.Info("Fetch the ou property in the AD");
                Fetch_OU_ADProperty(userList);
            }

            string fileName = FileNameTool.GetFileName("TfsExtractUsersList");

            using (CsvWriter csv = new CsvWriter(new StreamWriter(fileName)))
            {
                csv.Configuration.RegisterClassMap <ProjectDefinitionCsvMap>();
                csv.WriteExcelSeparator();

                if (this.extractOUOption)
                {
                    csv.WriteRecords(userList.Where(x => !string.IsNullOrEmpty(x.OU) && !x.OU.StartsWith(Environment.GetEnvironmentVariable("LDAP_OU_FILTER_OUT"))).DistinctBy(x => x.OU).OrderBy(x => x.Name));
                }
                else
                {
                    csv.WriteRecords(userList.DistinctBy(x => x.Mail).OrderBy(x => x.Name));
                }
            }

            logger.Info("Extract Users done");
        }
        public void Execute()
        {
            logger.Info("Extract Project List in progress...");
            ICollection <ProjectDefinition> projectList = TeamProjectHelper.GetAllProjects(configurationServer);

            string fileName = FileNameTool.GetFileName("TfsExtractProjectList");

            using (CsvWriter csv = new CsvWriter(new StreamWriter(fileName)))
            {
                csv.Configuration.RegisterClassMap <ProjectDefinitionCsvMap>();
                csv.WriteExcelSeparator();
                csv.WriteRecords(projectList);
            }

            logger.Info("Extract Project done");
        }
        public void Execute()
        {
            logger.Info("Extract Build Machines in progress...");
            ICollection <BuildServiceHostDefinition> buildServiceHostList = BuildServerHelper.GetAllBuildServiceHosts(configurationServer);

            ArrayList records = new ArrayList();

            foreach (BuildServiceHostDefinition buildServiceHostDefinition in buildServiceHostList)
            {
                foreach (BuildControllerDefinition controller in buildServiceHostDefinition.BuildControllers)
                {
                    records.Add(
                        new {
                        HostName       = buildServiceHostDefinition.Name,
                        IP             = GetIPFromHostName(buildServiceHostDefinition.Name),
                        CollectionName = buildServiceHostDefinition.CollectionName,
                        ServiceType    = "Controller",
                        ServiceName    = controller.Name,
                        Status         = controller.Status
                    });
                }
                foreach (BuildAgentDefinition agent in buildServiceHostDefinition.BuildAgents)
                {
                    records.Add(
                        new
                    {
                        HostName       = buildServiceHostDefinition.Name,
                        IP             = GetIPFromHostName(buildServiceHostDefinition.Name),
                        CollectionName = buildServiceHostDefinition.CollectionName,
                        ServiceType    = "Agent",
                        ServiceName    = agent.Name,
                        Status         = agent.Status
                    });
                }
            }

            string fileName = FileNameTool.GetFileName("TfsExtractMachineList");

            using (CsvWriter csv = new CsvWriter((new StreamWriter(fileName))))
            {
                csv.WriteExcelSeparator();
                csv.WriteRecords(records);
            }

            logger.Info("Extract Build Machines done");
        }
Exemple #4
0
        private void _003CInitEvent_003Eb__9(object sender, MouseButtonEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.FileName         = FileNameTool.PureFileName(fileItem.FileName);
            saveFileDialog.DefaultExt       = ".pdf";
            saveFileDialog.Filter           = "PDF documents (.pdf)|*.pdf";
            bool?flag  = saveFileDialog.ShowDialog();
            bool?flag2 = flag;

            if (flag2.GetValueOrDefault() && flag2.HasValue)
            {
                string text     = Path.Combine(fileItem.UnZipFilePath, "PDf.pdf");
                string fileName = saveFileDialog.FileName;
                if (File.Exists(text))
                {
                    File.Copy(text, fileName, true);
                }
            }
        }
Exemple #5
0
        private void InitEvent()
        {
            btnExport.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnExport.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnExport.MouseLeftButtonDown += (sender, e) =>
            {
                Task.Factory.StartNew(() => {
                    Singleton_PDFFactory.AddBookInPDFWork(fileItem.ID);
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        sb.Begin();
                        DataTable dt = MSCE.GetDataTable("select PDFFactoryParameterJson from FileRow where userid=@1 and id=@2"
                                                         , fileItem.UserID
                                                         , fileItem.ID);
                        if (dt.Rows.Count > 0)
                        {
                            PDFFactoryParameter pdfFactoryParameter = JsonConvert.DeserializeObject <PDFFactoryParameter>(dt.Rows[0][0].ToString());
                            Home home = Application.Current.Windows.OfType <Home>().First();

                            if (home.IsInSync == true)
                            {
                                pdfFactoryParameter.UserAccount += "_Sync";
                            }

                            Singleton_PDFFactory.SavePDF(pdfFactoryParameter);
                        }
                    }));
                    Singleton_PDFFactory.RemoveBookInPDFWork(fileItem.ID);
                });
            };

            btnDownload.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnDownload.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnDownload.MouseLeftButtonDown += (sender, e) =>
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                //Environment.SpecialFolder.MyDocuments
                //This cannot be found as it is not a valid path, so nothing gets selected.
                dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dlg.FileName         = FileNameTool.PureFileName(fileItem.FileName); // Default file name
                dlg.DefaultExt       = ".pdf";                                       // Default file extension
                dlg.Filter           = "PDF documents (.pdf)|*.pdf";                 // Filter files by extension
                // Show save file dialog box
                Nullable <bool> result = dlg.ShowDialog();
                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    string srcFilePath  = System.IO.Path.Combine(fileItem.UnZipFilePath, "PDF.pdf");
                    string saveFilePath = dlg.FileName;
                    if (File.Exists(srcFilePath) == true)
                    {
                        File.Copy(srcFilePath, saveFilePath, true);
                    }
                }
            };


            //偵測是否轉檔中
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(1100);
            timer.Tick    += (sender, e) =>
            {
                if (Singleton_PDFFactory.IsPDFInWork(fileItem.ID) == true)
                {
                    //this.Dispatcher.BeginInvoke(new Action(() =>
                    //    {
                    //        //Console.Write(sb.GetIsPaused());
                    //        //sb.Begin();
                    //    }));
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        pdfStatus              = PDFStatus.匯出中;
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
                else if (File.Exists(System.IO.Path.Combine(fileItem.UnZipFilePath, "PDF.pdf")) == true && fileItem.FileType == MeetingFileType.已下載完成)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sb.Stop();
                        pdfStatus              = PDFStatus.匯出成功;
                        btnExport.Visibility   = Visibility.Visible;
                        btnDownload.Visibility = Visibility.Visible;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
                else
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sb.Stop();
                        pdfStatus              = PDFStatus.尚未匯出;
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
            };
            timer.Start();
        }
Exemple #6
0
        public string CreateFolder <T>(T t, string fileId, string folderName)
        {
            Log.WriteLog("Create OneDrive folder content.");
            string token = t as string;

            /*
             * Request URL:
             * https://graph.microsoft.com/v1.0/me/drive/root/children [Root]
             * https://graph.microsoft.com/v1.0/me/drive/items/1C1370877CDEA235!105/children
             * Authorization bearer token
             */

            if (string.IsNullOrEmpty(token))
            {
                Log.WriteLog("OneDrive :  token is null.");
                return(null);
            }

            if (string.IsNullOrEmpty(fileId))
            {
                Log.WriteLog("OneDrive :  Create target folder parent is null.");
                fileId = "root";
            }

            string hostURL              = "graph.microsoft.com";
            string authContent          = "bearer " + token;
            List <HeaderEntity> headers = new List <HeaderEntity>
            {
                new HeaderEntity("SdkVersion", "Graph-dotnet-1.6.2"),
                new HeaderEntity("Authorization", authContent),
                new HeaderEntity("SampleID", "uwp-csharp-connect-sample"),
                new HeaderEntity("Cache-Control", "no-store, no-cache"),
                new HeaderEntity("Content-Type", "application/json"),
                new HeaderEntity("Host", hostURL)
            };

            //Check Request is Root folder
            string requestURL = "";

            if (fileId.ToLower() == "root" || fileId == "/")
            {
                requestURL = "/v1.0/me/drive/root/children";
            }
            else
            {
                requestURL = "/v1.0/me/drive/items/" + fileId + "/children";
            }
            string            postData         = "";
            CreateFolderModel createFolderItem = new CreateFolderModel();

            createFolderItem.name   = FileNameTool.GetValidFileName(folderName);
            createFolderItem.folder = new FolderData();
            try
            {
                postData = JsonConvert.SerializeObject(createFolderItem);
            }
            catch (Exception ex)
            {
                postData = "";
                Log.WriteLog("Create OneDriver exception:" + ex.Message);
            }
            if (string.IsNullOrEmpty(postData))
            {
                return(null);
            }
            string    folderId  = "";
            NetClient netclient = new NetClient(headers);

            try
            {
                string jsonContent = netclient.POST(postData, hostURL, requestURL, false, true);
                if (!string.IsNullOrEmpty(jsonContent))
                {
                    ValueItem valueItem = JsonConvert.DeserializeObject <ValueItem>(jsonContent);
                    if (valueItem != null)
                    {
                        folderId = valueItem.id;
                    }
                }
            }
            catch (WebException ex)
            {
                folderId = "";
                Log.WriteLog("Search OneDrive folder content webexception:" + ex.Message);
            }
            catch (Exception ex)
            {
                folderId = "";
                Log.WriteLog("Search OneDrive folder content exception:" + ex.Message);
            }
            finally
            {
                if (netclient != null)
                {
                    netclient.Dispose();
                    netclient = null;
                }
            }
            return(folderId);
        }