public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { DataLinks dl = new DataLinks(); object cn; if (value != null && !value.Equals("")) { cn = new Connection(); ((Connection) cn).ConnectionString = value.ToString(); dl.PromptEdit(ref cn); } else cn = dl.PromptNew(); return ((Connection) cn).ConnectionString; }
/// <summary> /// Asks user with nice standard dialog-box about the settings of the connection to the database. /// It returns 'true' when user defined a (valid) connection and pressed [OK] button, /// otherwise 'false'. In case of edition of an existing connection, pass it via /// <paramref name="initialConnectionString"/> parameter. /// </summary> public static bool PromptConnectionString(string initialConnectionString, out string userConnectionString) { DataLinks sysConnectionDialog = new DataLinks(); _Connection adoConnection; initialConnectionString = UnsecureConnectionString(initialConnectionString); if (string.IsNullOrEmpty(initialConnectionString)) { // get the connection object from the dialog: adoConnection = (_Connection)sysConnectionDialog.PromptNew(); } else { try { // create the connection object and pass it to the dialog: adoConnection = new ConnectionClass(); adoConnection.ConnectionString = initialConnectionString; object oConnection = adoConnection; // and if user clicked [NO] on the dialog, release the connection object // to return 'false' and empty string... if (!sysConnectionDialog.PromptEdit(ref oConnection)) { adoConnection = null; } } catch (Exception ex) { Trace.WriteLine(ex.Message); Trace.WriteLine(ex.StackTrace); // create the connection object without passing the connection string // as this probably was incorrect and caused an error: adoConnection = (_Connection)sysConnectionDialog.PromptNew(); } } if (adoConnection != null) { userConnectionString = adoConnection.ConnectionString; return(true); } // otherwise return the default connection info: userConnectionString = null; return(false); }
private void btSetConnectionString_Click(object sender, EventArgs e) { DataLinks mydlg = new DataLinks(); if (ConnectionString == null) { var connectionStringAdo = (Connection)mydlg.PromptNew(); ConnectionString = connectionStringAdo.ConnectionString; } else { Connection con = new Connection(); con.ConnectionString = ConnectionString; object x = con; if (mydlg.PromptEdit(ref x)) { con = x as Connection; } ConnectionString = con.ConnectionString; } ConfigLoader.Save(ConnectionString); }
public IHttpActionResult Export([FromUri] string exportType) { //var userId = User.Identity.GetUserId(); //var user = unitOfWork.User.Get(userId); var user = unitOfWork.User.Get("appu"); var userId = user.Id; var usertype = ConvertIntToString(user.UserType.TypeOfUser); DataLinks links; try { string imgPath = string.Empty; if (!string.IsNullOrEmpty(user.Files)) { imgPath = $"{GetUserFolderPath(userId)}/{user.Files}"; } var folderPath = GetUserDocumentFolderPath(userId); CreateUserFolder(folderPath); //var userPath = $"{folderPath}\\{user.Id}"; var userPath = $"{folderPath}"; localHost += $"{userId}/"; if (exportType.Split('.').Length > 1) { Exporter.ExportCsv(userPath, user, usertype, localHost, out Uri dataPath, out Uri ppPath); Exporter.ExportPdf(userPath, user, usertype, localHost, imgPath, out Uri dataPdfPath); links = new DataLinks(dataPath, ppPath, dataPdfPath); string[] stringSeparators = new string[] { $"\\{user.Id}" }; //ne moze se zipovati onaj direktorijum koji koristimo promeniti puvanju na bude u istoj ravnini sa appu a ne u appu using (FileStream zipFile = File.Open(userPath.Split(stringSeparators, StringSplitOptions.None)[0] + $"\\{user.Name}.zip", FileMode.Create)) using (Archive archive = new Archive()) { DirectoryInfo corpus = new DirectoryInfo(folderPath); archive.CreateEntries(corpus); archive.Save(zipFile); return(GetDocuments(userPath, user.Name, "zip")); } //return GetDocuments(userPath, user.Name, "csv"); //return GetDocuments(userPath, user.Name, "pdf"); } else if (exportType.Equals("csv")) { Exporter.ExportCsv(userPath, user, usertype, localHost, out Uri dataPath, out Uri ppPath); links = new DataLinks(dataPath, ppPath, null); using (FileStream zipFile = File.Open(userPath + $"\\{user.Name}CSV.zip", FileMode.Create)) { // Files to be added to archive FileInfo fi1 = new FileInfo($"{userPath}\\{user.Name}{user.Surname}.csv"); FileInfo fi2 = new FileInfo($"{userPath}\\{user.Name}{user.Surname}PayPal.csv"); using (var archive = new Archive()) { archive.CreateEntry($"{userPath}\\{user.Name}{user.Surname}.csv", fi1); archive.CreateEntry($"{userPath}\\{user.Name}{user.Surname}PayPal.csv", fi2); archive.Save(zipFile, new ArchiveSaveOptions() { Encoding = Encoding.UTF8 }); } } return(GetDocuments(userPath, $"{user.Name}CSV", "zip")); } else if (exportType.Equals("pdf")) { Exporter.ExportPdf(userPath, user, usertype, localHost, imgPath, out Uri dataPdfPath); links = new DataLinks(null, null, dataPdfPath); return(GetDocuments(userPath, user.Name, "pdf")); } else { links = new DataLinks(null, null, null); } return(Ok(links)); } catch (Exception ex) { //log } return(Ok(HttpStatusCode.NoContent)); }
// private void optSqlProvider_CheckedChanged(object sender, EventArgs e) { // pnlSqlProvider.Visible = true; // pnlOleDbProvider.Visible = false; // } // private void optOleDbProvider_CheckedChanged(object sender, EventArgs e) { // pnlSqlProvider.Visible = false; // pnlOleDbProvider.Visible = true; // } private void cmdBuild_Click(object sender, EventArgs e) { DataLinks dl = new DataLinks(); object cn; if (!txtConnectionString.Equals("")) { cn = new Connection(); ((Connection) cn).ConnectionString = txtConnectionString.Text; dl.PromptEdit(ref cn); } else { cn = (Connection) dl.PromptNew(); } txtConnectionString.Text = ((Connection) cn).ConnectionString; }