public void svcHTTPFileTransferServiceUploadFileToInstallationDirectory(RemoteFileInfo request) { if (EntsvcHTTPFileTransferServiceUploadFileToInstallationDirectory != null) { EntsvcHTTPFileTransferServiceUploadFileToInstallationDirectory(request); } }
public void svcHTTPFileTransferServiceUploadFile(RemoteFileInfo request) { if (EntsvcHTTPFileTransferServiceUploadFile != null) { EntsvcHTTPFileTransferServiceUploadFile(request); } }
void btnSubmit_Click(object sender, RoutedEventArgs e) { try { #region cheking if (ofd.FileName == null || ofd.FileName == "") { System.Windows.MessageBox.Show("Browse the File to Upload"); txtUpload.Focus(); return; } if (cmbAssembly.SelectedItem == null) { System.Windows.MessageBox.Show("Select the Assembly File"); cmbAssembly.Focus(); return; } if (cmbClass.SelectedItem == null) { System.Windows.MessageBox.Show("Select the Class Name"); cmbClass.Focus(); return; } if (txtModule.Text == "" || txtModule.Text == null) { System.Windows.MessageBox.Show("Enter Module Name"); txtModule.Focus(); return; } if (!new ClsModuleLogic().ModuleExists(txtModule.Text)) { System.Windows.MessageBox.Show("Specify another module name"); txtModule.Focus(); return; } if (!IsVersionValid()) { System.Windows.MessageBox.Show("Enter Valid Version Number"); txtVersion.Focus(); return; } #endregion try { DirectoryInfo diZip = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Zip Files"); File.Copy(ofd.FileName, diZip.FullName + "\\" + ofd.SafeFileName); DirectoryInfo diModule = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Modules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(diModule.FullName + "\\" + ofd.SafeFileName.Split('.')[0])) { fz.ExtractZip(diZip.FullName + "\\" + ofd.SafeFileName, diModule.FullName, null); } // Upload the Zip file To bs System.IO.FileStream stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); RemoteFileInfo rfiUpload = new RemoteFileInfo(); rfiUpload.FileName = ofd.SafeFileName; rfiUpload.FolderNameToStore = ""; rfiUpload.FileByteStream = stream; rfiUpload.Length = stream.Length; clientHttpChannelFileTransfer.svcHTTPFileTransferServiceUploadFile(rfiUpload); stream.Flush(); stream.Close(); FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); rfiUpload.FileByteStream = fs; clientHttpChannelFileTransfer.svcHTTPFileTransferServiceUploadFileToInstallationDirectory(rfiUpload); fs.Flush(); fs.Close(); } catch (Exception ex) { System.Windows.MessageBox.Show("The Zip File is already uploaded please select another File"); VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSubmit_Click()", "Controls\\CtlUploadModule.xaml.cs"); return; } ClsModuleLogic cml = new ClsModuleLogic(); TextRange tr = new TextRange(rtbDescription.Document.ContentStart, rtbDescription.Document.ContentEnd); #region Creating byte array of imagefile List<byte[]> ImageByte = new List<byte[]>(); if (!string.IsNullOrEmpty(txtModuleImage.Text)) { byte[] b = SetImage(txtModuleImage.Text); if (b != null) { ImageByte.Add(b); } else { b = SetImage(AppDomain.CurrentDomain.BaseDirectory + "\\Skins\\Images\\Help.png"); if (b != null) { ImageByte.Add(b); } } } else { byte[] b = SetImage(AppDomain.CurrentDomain.BaseDirectory + "\\Skins\\Images\\Help.png"); if (b != null) { ImageByte.Add(b); } } #endregion int intModId = -1; intModId = cml.AddModule(-1, txtModule.Text, txtVersion.Text, tr.Text, ((ComboBoxItem)cmbAssembly.SelectedItem).Content.ToString(), ((ComboBoxItem)cmbClass.SelectedItem).Content.ToString(), txtZip.Text, 1, ckbCollaborate.IsChecked.Value, ckbAuthentication.IsChecked.Value, ImageByte[0]); if (intModId == -1) { System.Windows.MessageBox.Show("Report this error to your administrator"); return; } ClsPermissionLogic cpl = new ClsPermissionLogic(); foreach (object chk in grid1.Children) { if (chk.GetType() == typeof(System.Windows.Controls.CheckBox) && ((System.Windows.Controls.CheckBox)chk).Tag != null) { int i = 0; string[] strPermission = (((System.Windows.Controls.CheckBox)chk).Tag).ToString().Split(','); for (i = 0; i < objModulePermissions.Count; i++) { if (objModulePermissions[i].PermissionName == strPermission[0]) { break; } } if (i == objModulePermissions.Count) { objModulePermissions.Add(new clsModulePermission(intModId, cpl.Add_Permission(-1, intModId, strPermission[0], int.Parse(strPermission[1])), strPermission[0], int.Parse(strPermission[1]))); } if (((System.Windows.Controls.CheckBox)chk).IsChecked == true) { for (int j = 0; j < objModulePermissions.Count; j++) { if (objModulePermissions[j].PermissionName == strPermission[0]) { cpl.Add_ModulePermission(objModulePermissions[j].PermissionID, int.Parse(strPermission[2])); ((System.Windows.Controls.CheckBox)chk).IsChecked = false; break; } } } } } System.Windows.MessageBox.Show("Module Uploaded"); txtUpload.Clear(); txtZip.Clear(); cmbAssembly.Items.Clear(); cmbClass.Items.Clear(); txtModule.Clear(); txtVersion.Clear(); ckbCollaborate.IsChecked = false; rtbDescription.SelectAll(); rtbDescription.Selection.Text = ""; ckbAuthentication.IsChecked = false; txtModuleImage.Text = ""; if (grid1.Children.Count > 0) { grid1.Children.Clear(); } objModulePermissions.Clear(); } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSubmit_Click()--1", "Controls\\CtlUploadModule.xaml.cs"); } }
RemoteFileInfo BootstrapServiceDomain_EntsvcHTTPFileTransferServiceDownloadFile(DownloadRequest request) { string filePath; string installerPath; System.IO.FileInfo fileInfo; string configurationFilePath; string basePath; try { Assembly ass = Assembly.GetEntryAssembly(); XmlDocument xDoc = new XmlDocument(); configurationFilePath = (Assembly.GetAssembly(this.GetType()).Location.Replace("VMukti.Presentation.exe", "")); configurationFilePath += @"sqlceds35.dll"; xDoc.Load(configurationFilePath); XmlNode xn = xDoc.SelectSingleNode("/Root/OtherSettings/PhysicalPathOfVirtualDirectory"); basePath = DecodeBase64String(xn.Attributes[0].Value); installerPath = basePath + "\\" + request.FolderWhereFileIsStored; //Check if directory specified exists if (Directory.Exists(installerPath)) { //Get info about the input file filePath = System.IO.Path.Combine(installerPath, request.FileName); fileInfo = new System.IO.FileInfo(filePath); // check if exists if (!fileInfo.Exists) { ClsException.WriteToLogFile("BootstrapServiceDomain_EntsvcHTTPFileTransferServiceDownloadFile()--:--BootStrapDomain.cs--:--File Not Found(" + request.FileName + ")" + " :--:--"); } // open stream System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); RemoteFileInfo result = new RemoteFileInfo(); result.FileName = request.FileName; result.Length = fileInfo.Length; result.FileByteStream = stream; return result; } else { ClsException.WriteToLogFile("BootstrapServiceDomain_EntsvcHTTPFileTransferServiceDownloadFile()--:--BootStrapDomain.cs--:--" + "Directory Not Found(" + request.FolderWhereFileIsStored + ")" + " :--:--"); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "BootStrapServiceDomain_EntsvcNetP2pFileTransferServiceUploadFileScript()", "Domains\\BootstrapServiceDomain.cs"); } return null; }
void BootstrapServiceDomain_EntsvcHTTPFileTransferServiceUploadFileToInstallationDirectory(RemoteFileInfo request) { string filePath; string configurationFilePath; string installerPath; string basePath; try { Assembly ass = Assembly.GetEntryAssembly(); XmlDocument xDoc = new XmlDocument(); configurationFilePath = (Assembly.GetAssembly(this.GetType()).Location.Replace("VMukti.Presentation.exe", "")); configurationFilePath += @"sqlceds35.dll"; xDoc.Load(configurationFilePath); XmlNode xn = xDoc.SelectSingleNode("/Root/OtherSettings/PhysicalPathOfVirtualDirectory"); basePath = DecodeBase64String(xn.Attributes[0].Value); installerPath = basePath + "\\" + request.FolderNameToStore; if (!Directory.Exists(installerPath)) { Directory.CreateDirectory(installerPath); } filePath = System.IO.Path.Combine(installerPath, request.FileName); if (System.IO.File.Exists(filePath)) System.IO.File.Delete(filePath); int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write)) { do { // read bytes from input stream int bytesRead = request.FileByteStream.Read(buffer, 0, chunkSize); if (bytesRead == 0) break; // write bytes to output stream writeStream.Write(buffer, 0, bytesRead); } while (true); writeStream.Close(); } //extracting the file uploaded in zip files folder to modules folder //if (request.FolderNameToStore == "Zip Files") //{ // DirectoryInfo diModule = new DirectoryInfo(basePath + "\\Modules"); // VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); // if (!Directory.Exists(diModule.FullName + "\\" + request.FileName.Split('.')[0])) // { // fz.ExtractZip(installerPath + "\\" + request.FileName, diModule.FullName, null); // } //} } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "BootStrapServiceDomain_EntsvcHTTPFileTransferServiceUploadFileToInstallationDirectory()", "Domains\\BootstrapServiceDomain.cs"); } }
void BootstrapServiceDomain_EntsvcHTTPFileTransferServiceUploadFile(RemoteFileInfo request) { string filePath; string baseDirectory; string installerPath; try { baseDirectory = (Assembly.GetAssembly(this.GetType()).Location.Replace("VMukti.Presentation.exe", "")); installerPath = baseDirectory; installerPath += request.FolderNameToStore; if (!Directory.Exists(installerPath)) { Directory.CreateDirectory(installerPath); } filePath = System.IO.Path.Combine(installerPath, request.FileName); if (System.IO.File.Exists(filePath)) System.IO.File.Delete(filePath); int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write)) { do { // read bytes from input stream int bytesRead = request.FileByteStream.Read(buffer, 0, chunkSize); if (bytesRead == 0) break; // write bytes to output stream writeStream.Write(buffer, 0, bytesRead); } while (true); writeStream.Close(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "BootStrapServiceDomain_EntsvcHTTPFileTransferServiceUploadFile()", "Domains\\BootstrapServiceDomain.cs"); } }