public CtlUploadModule() { try { InitializeComponent(); ass = Assembly.GetAssembly(typeof(CtlUploadModule)); btnUpload.Click += new RoutedEventHandler(btnUpload_Click); btnBrowseMouleImage.Click += new RoutedEventHandler(btnBrowseMouleImage_Click); btnSubmit.Click += new RoutedEventHandler(btnSubmit_Click); btnCancel.Click += new RoutedEventHandler(btnCancel_Click); cmbAssembly.SelectionChanged += new SelectionChangedEventHandler(cmbAssembly_SelectionChanged); this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(CtlUploadModule_IsVisibleChanged); BasicHttpClient bhcFiletransfer = new BasicHttpClient(); clientHttpChannelFileTransfer = (IHTTPFileTransferService)bhcFiletransfer.OpenClient <IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpChannelFileTransfer.svcHTTPFileTransferServiceJoin(); } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CtlUploadModule()", "Controls\\CtlUploadModule.xaml.cs"); } }
private int downloadAndExtractZipFiles() { try { crm = CRMName; crm += "_CRM"; Assembly ass = Assembly.GetEntryAssembly(); filename = crm + ".zip"; #region Download Zip File using WCF FileTranserService try { BasicHttpClient bhcFtsj = new BasicHttpClient(); clientHttpFileTransfer = (IHTTPFileTransferService)bhcFtsj.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); DownloadRequest request = new DownloadRequest(); RemoteFileInfo rfi = new RemoteFileInfo(); request.FileName = filename; request.FolderWhereFileIsStored = "CRMs"; rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(request); //rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(destination); //rfi=clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile( ("D:\Users\KLS\CRMDesignerTestApplication\CRMDesigner_TestApplication\bin\Debug"); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs")); } destination = ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"); filePath = destination + "\\" + filename; System.IO.Stream inputStream = rfi.FileByteStream; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, FileShare.ReadWrite)) { int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; do { // read bytes from input stream int bytesRead = inputStream.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, "downloadAndExtractZipFiles(Download Zip File)", "ctlCRMDesigner.xaml.cs"); return -1; } #endregion #region Extracting if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules")); } try { crm = CRMName; crm += "_CRM"; Assembly ass2 = Assembly.GetEntryAssembly(); crmModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"CRMModules"); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "downloadAndExtractZipFiles(Extracting)", "ctlCRMDesigner.xaml.cs"); } try { VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); //ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip(); //if (!Directory.Exists(crmModPath + "\\" + crm)) { //fz.ExtractZip(destination + "\\" + filename, crmModPath , null); fz.ExtractZip(destination + "\\" + filename, crmModPath + "\\" + crm, null); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "downloadAndExtractZipFiles(creating zip)", "ctlCRMDesigner.xaml.cs"); } #endregion } catch (Exception ex) { //VMuktiHelper.ExceptionHandler(ex, "downloadAndExtractZipFiles(Outer)", "ctlCRMDesigner.xaml.cs"); return -1; } return 0; }
//public ctlCRMDesigner(ModulePermissions[] MyPermissions) //{ // try // { // //InitializeComponent(); // this.Loaded += new RoutedEventHandler(ctlCRMDesigner_Loaded); // _MyPermissions = MyPermissions; // FncPermissionsReview(); // currentControl = new ctlPOD(); // MyPropGrid = new ctlPropertyGrid(); // FncFillCombo(); // //cmbScript.SelectionChanged += new SelectionChangedEventHandler(cmbScript_SelectionChanged); // txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); // lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); // btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click); // cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop); // //tbi.Drop += new DragEventHandler(tbi_Drop); // cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver); // cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp); // cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown); // cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove); // cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove); // currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged); // cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged); // r1.Stroke = Brushes.White; // r1.StrokeThickness = 3.0; // r1.Fill = Brushes.Transparent; // r1.StrokeDashArray = new DoubleCollection(2); // MyPropGrid.Height = 500; // MyPropGrid.Width = 200; // MyPropGrid.SetValue(Canvas.LeftProperty, 650.0); // MyPropGrid.SetValue(Canvas.TopProperty, 0.0); // myExpander1.Content = MyPropGrid; // myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded); // myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed); // //cnvPaint.Children.Add(MyPropGrid); // cnvPaint.Children.Add(r1); // r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged); // this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown); // FncCreateTabItems(); // txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown); // txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown); // txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus); // txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus); // txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus); // txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString(); // txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString(); // ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll(); // for (int i = 0; i < objClsCRMCollection.Count; i++) // { // ComboBoxItem cmb1 = new ComboBoxItem(); // cmb1.Content = objClsCRMCollection[i].CRMName; // cmb1.Tag = objClsCRMCollection[i].ID; // cmbCRM.Items.Add(cmb1); // } // try // { // BasicHttpClient bhcFts = new BasicHttpClient(); // clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); // clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); // } // catch (Exception ex) // { // ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--ctlCRMDesigner()--"); // //ClsException.LogError(ex); // //ClsException.WriteToErrorLogFile(ex); // System.Text.StringBuilder sb = new StringBuilder(); // sb.AppendLine(ex.Message); // sb.AppendLine(); // sb.AppendLine("StackTrace : " + ex.StackTrace); // sb.AppendLine(); // sb.AppendLine("Location : " + ex.Data["My Key"].ToString()); // sb.AppendLine(); // sb1 = CreateTressInfo(); // sb.Append(sb1.ToString()); // VMuktiAPI.ClsLogging.WriteToTresslog(sb); // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } //} public ctlCRMDesigner(string TempCRM) { InitializeComponent(); CRMName = TempCRM; currentControl = new ctlPOD(); MyPropGrid = new ctlPropertyGrid(); this.Loaded+=new RoutedEventHandler(ctlCRMDesigner_Loaded); FncFillCombo(); flag = false; txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click); cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop); //tbi.Drop += new DragEventHandler(tbi_Drop); cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver); cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp); cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown); cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove); cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove); currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged); r1.Stroke = Brushes.White; r1.StrokeThickness = 3.0; r1.Fill = Brushes.Transparent; r1.StrokeDashArray = new DoubleCollection(2); MyPropGrid.Height = 500; MyPropGrid.Width = 200; MyPropGrid.SetValue(Canvas.LeftProperty, 650.0); MyPropGrid.SetValue(Canvas.TopProperty, 0.0); myExpander1.Content = MyPropGrid; myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded); myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed); //cnvPaint.Children.Add(MyPropGrid); cnvPaint.Children.Add(r1); r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged); this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown); FncCreateTabItems(); txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown); txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown); txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus); txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus); txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus); txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString(); txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString(); //lblCRM.Visibility = Visibility.Collapsed; //cmbCRM.Visibility = Visibility.Collapsed; //btnGetQuestions.Visibility = Visibility.Collapsed; ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll(); for (int i = 0; i < objClsCRMCollection.Count; i++) { ComboBoxItem cmb1 = new ComboBoxItem(); cmb1.Content = objClsCRMCollection[i].CRMName; cmb1.Tag = objClsCRMCollection[i].ID; cmbCRM.Items.Add(cmb1); if (objClsCRMCollection[i].ID.ToString() == CRMName) { cmbCRM.Text = cmb1.Content.ToString(); } } //cmbCRM.Text = CRMName; cmbCRM.IsEnabled = false; cmbCRM.SelectionChanged+=new SelectionChangedEventHandler(cmbCRM_SelectionChanged); cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged); try { BasicHttpClient bhcFts = new BasicHttpClient(); clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "ctlCRMDesigner()", "ctlCRMDesigner.xaml.cs"); } GetQuestions(); //return 0; }
public ctlCRMDesigner(ModulePermissions[] MyPermissions) { try { InitializeComponent(); this.Loaded += new RoutedEventHandler(ctlCRMDesigner_Loaded); _MyPermissions = MyPermissions; FncPermissionsReview(); currentControl = new ctlPOD(); MyPropGrid = new ctlPropertyGrid(); FncFillCombo(); //cmbScript.SelectionChanged += new SelectionChangedEventHandler(cmbScript_SelectionChanged); txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click); cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop); //tbi.Drop += new DragEventHandler(tbi_Drop); cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver); cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp); cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown); cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove); cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove); currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged); cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged); r1.Stroke = Brushes.White; r1.StrokeThickness = 3.0; r1.Fill = Brushes.Transparent; r1.StrokeDashArray = new DoubleCollection(2); MyPropGrid.Height = 500; MyPropGrid.Width = 200; MyPropGrid.SetValue(Canvas.LeftProperty, 650.0); MyPropGrid.SetValue(Canvas.TopProperty, 0.0); myExpander1.Content = MyPropGrid; myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded); myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed); //cnvPaint.Children.Add(MyPropGrid); cnvPaint.Children.Add(r1); r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged); this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown); FncCreateTabItems(); txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown); txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown); txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus); txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus); txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus); txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString(); txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString(); ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll(); for (int i = 0; i < objClsCRMCollection.Count; i++) { ComboBoxItem cmb1 = new ComboBoxItem(); cmb1.Content = objClsCRMCollection[i].CRMName; cmb1.Tag = objClsCRMCollection[i].ID; cmbCRM.Items.Add(cmb1); } try { BasicHttpClient bhcFts = new BasicHttpClient(); clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); } catch (Exception ex) { ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--ctlCRMDesigner()--"); //ClsException.LogError(ex); //ClsException.WriteToErrorLogFile(ex); System.Text.StringBuilder sb = new StringBuilder(); sb.AppendLine(ex.Message); sb.AppendLine(); sb.AppendLine("StackTrace : " + ex.StackTrace); sb.AppendLine(); sb.AppendLine("Location : " + ex.Data["My Key"].ToString()); sb.AppendLine(); sb1 = CreateTressInfo(); sb.Append(sb1.ToString()); VMuktiAPI.ClsLogging.WriteToTresslog(sb); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public CtlUploadModule() { try { InitializeComponent(); ass = Assembly.GetAssembly(typeof(CtlUploadModule)); btnUpload.Click += new RoutedEventHandler(btnUpload_Click); btnBrowseMouleImage.Click += new RoutedEventHandler(btnBrowseMouleImage_Click); btnSubmit.Click += new RoutedEventHandler(btnSubmit_Click); btnCancel.Click += new RoutedEventHandler(btnCancel_Click); cmbAssembly.SelectionChanged += new SelectionChangedEventHandler(cmbAssembly_SelectionChanged); this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(CtlUploadModule_IsVisibleChanged); BasicHttpClient bhcFiletransfer = new BasicHttpClient(); clientHttpChannelFileTransfer = (IHTTPFileTransferService)bhcFiletransfer.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpChannelFileTransfer.svcHTTPFileTransferServiceJoin(); } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CtlUploadModule()", "Controls\\CtlUploadModule.xaml.cs"); } }
int DownloadAndExtractZipFile() { str = CRMName; str = str + "_CRM"; //Retrives the Assembly of the Zip file. Assembly ass = Assembly.GetEntryAssembly(); #region Downloading ZipFile //Set the Variable. filename = str + ".zip"; //string strModPath = ""; #region Download Zip File using WCF FileTranserService //Download file using WCF FileTransferService try { //Create object of the HTTP Client. BasicHttpClient bhcFts = new BasicHttpClient(); //Open Client. clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient <IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); //Join the network. clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); //Create request to download File from Bootstrap. DownloadRequest request = new DownloadRequest(); //Providing the information of the file that needs to download. RemoteFileInfo rfi = new RemoteFileInfo(); request.FileName = filename; request.FolderWhereFileIsStored = "CRMs"; //Calling the WCF Function for downloading the File. rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(request); //Checking for Directory Existence. //if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs")); } destination = ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"); //Checking for File Existance. if (File.Exists((destination + "\\" + filename))) { File.Delete((destination + "\\" + filename)); } filePath = destination + "\\" + filename; System.IO.Stream inputStream = rfi.FileByteStream; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write)) { int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; do { // read bytes from input stream int bytesRead = inputStream.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) { //MessageBox.Show("Download Zip: " + ex.Message); VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); if (ex.InnerException != null) { //MessageBox.Show("Download Zip Inner Exception: " + ex.InnerException.Message); VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); } } #endregion #region Downloading using Web Client --------Commented //try //{ // Uri u = new Uri("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + "/VMukti/CRMs/" + filename); // if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) // { // Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs")); // } // destination = ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"); // if (!File.Exists(destination + "\\" + filename)) // { // WebClient wc = new WebClient(); // try // { // wc.DownloadFile(u, destination + "\\" + filename); // } // catch (Exception exp) // { // MessageBox.Show(exp.Message); // } // } //} //catch (Exception exp) //{ // MessageBox.Show("Down Load Error - " + exp.Message); //} #endregion #endregion #region Extracting //Code for Extracting the .zip file. try { //Checking for the Existance of the Directory. if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules")); } str = CRMName; str = str + "_CRM"; Assembly ass2 = Assembly.GetEntryAssembly(); strModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"CRMModules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); //ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip(); //FastZip fz = new FastZip(); //if (!Directory.Exists(strModPath + "\\" + filename.Split('.')[0])) //{ try { //Extracting the zip file. fz.ExtractZip(destination + "\\" + filename, strModPath + "\\" + str, null); } catch (Exception exp) { //MessageBox.Show(exp.Message + " First Desgine Required CRM Using CRMDesginer"); VMuktiHelper.ExceptionHandler(exp, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); } // } } catch (Exception exp) { VMuktiHelper.ExceptionHandler(exp, "DownloadAndExtractZipFile(Outer)", "CtlCRMContainer.xaml.cs"); return(-1); } #endregion return(0); }
int DownloadAndExtractZipFile() { #region Download and Extract Zip file try { str = ScriptName; str += "_Script"; Assembly ass = Assembly.GetEntryAssembly(); // this maybe something like "using Vmuktiapi" filename = str + ".zip"; #region Download Zip File using WCF FileTranserService try { BasicHttpClient bhcFts = new BasicHttpClient(); clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); DownloadRequest request = new DownloadRequest(); RemoteFileInfo rfi = new RemoteFileInfo(); request.FileName = filename; request.FolderWhereFileIsStored = "Scripts"; rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(request); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Scripts"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Scripts")); } destination = ass.Location.Replace("VMukti.Presentation.exe", @"Scripts"); filePath = destination + "\\" + filename; System.IO.Stream inputStream = rfi.FileByteStream; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, FileShare.ReadWrite)) { int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; do { // read bytes from input stream int bytesRead = inputStream.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) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs"); return -1; } #endregion #region Downloading ZipFile Using WebClient -----Commented #endregion #region Extracting if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"ScriptModules"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"ScriptModules")); } try { str = ScriptName; str += "_Script"; Assembly ass2 = Assembly.GetEntryAssembly(); strModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"ScriptModules"); } catch (Exception e) { VMuktiAPI.VMuktiHelper.ExceptionHandler(e, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs"); } ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip(); // if (!Directory.Exists(strModPath + "\\" + str )) { fz.ExtractZip(destination + "\\" + filename, strModPath+ "\\"+str, null); } #endregion } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs"); return -1; } #endregion return 0; }
///// //System.Windows.Forms.PropertyGrid propGrid = new System.Windows.Forms.PropertyGrid(); // Raxit code // public ctlScriptDesigner(string sName) { InitializeComponent(); ScriptName = sName; this.Loaded += new RoutedEventHandler(ctlScriptDesigner_Loaded); FncFillCombo(); cmbScript.SelectionChanged += new SelectionChangedEventHandler(cmbScript_SelectionChanged); flag = false; btnDrag.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown); txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); cmbDrag999.PreviewMouseDown += new MouseButtonEventHandler(cmbDrag999_PreviewMouseDown); lstDrag999.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown); chkDrag999.PreviewMouseDown += new MouseButtonEventHandler(chkDrag999_PreviewMouseDown); radDrag999.PreviewMouseDown += new MouseButtonEventHandler(radDrag999_PreviewMouseDown); txbDrag999.PreviewMouseDown += new MouseButtonEventHandler(txbDrag999_PreviewMouseDown); cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop); cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver); cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlScriptDesigner_PreviewMouseUp); cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlScriptDesigner_PreviewMouseDown); cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlScriptDesigner_MouseMove); cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove); currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged); cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged); btnBack.Click += new RoutedEventHandler(btnBack_Click); r1.Stroke = Brushes.White; r1.StrokeThickness = 3.0; r1.Fill = Brushes.Transparent; r1.StrokeDashArray = new DoubleCollection(2); MyPropGrid.Height = 550; MyPropGrid.Width = 200; MyPropGrid.SetValue(Canvas.LeftProperty, 600.0); myExpander1.Content = MyPropGrid; myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded); myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed); //cnvPaint.Children.Add(MyPropGrid); cnvPaint.Children.Add(r1); r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged); this.PreviewKeyDown += new KeyEventHandler(ctlScriptDesigner_PreviewKeyDown); lblScript.Visibility = Visibility.Collapsed; cmbScript.Visibility = Visibility.Collapsed; btnGetQuestions.Visibility = Visibility.Collapsed; // Adding Combobox and a Button to Next Page Bind cmbQuest.Height = 25; cmbQuest.Width = 150; cmbQuest.SetValue(Canvas.LeftProperty, 390.0); cmbQuest.SetValue(Canvas.TopProperty, 2.0); cnvHead.Children.Add(cmbQuest); btnBindQuestion.Height = 25; btnBindQuestion.Width = 50; btnBindQuestion.Content = "Bind"; btnBindQuestion.SetValue(Canvas.LeftProperty, 550.0); btnBindQuestion.SetValue(Canvas.TopProperty, 2.0); btnBindQuestion.Click += new RoutedEventHandler(btnBindQuestion_Click); cnvHead.Children.Add(btnBindQuestion); ///////////////////////////////////////////////// btnAPI.Click += new RoutedEventHandler(btnAPI_Click); btnDispo.Click += new RoutedEventHandler(btnDispo_Click); GetQuestions(); FncFillCampaign(); BasicHttpClient bhcFts = new BasicHttpClient(); clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); if (clsStartClass.ScriptName != null && clsStartClass.ScriptType != null) { string script = clsStartClass.ScriptName; string scriptType = clsStartClass.ScriptType; if (scriptType.Equals("Static")) { lblDrag999.SetValue(Canvas.LeftProperty, txtDrag999.GetValue(Canvas.LeftProperty)); lblDrag999.SetValue(Canvas.TopProperty, txtDrag999.GetValue(Canvas.TopProperty)); cnvControls.Children.Remove(txtDrag999); cnvControls.Children.Remove(cmbDrag999); cnvControls.Children.Remove(lstDrag999); cnvControls.Children.Remove(radDrag999); cnvControls.Children.Remove(chkDrag999); grdControls.Height = grdControls.Height - 160; //cmbDrag999.Visibility = Visibility.Collapsed; //lstDrag999.Visibility = Visibility.Collapsed; //radDrag999.Visibility = Visibility.Collapsed; //chkDrag999.Visibility = Visibility.Collapsed; } else { txtDrag999.Visibility = Visibility.Visible; cmbDrag999.Visibility = Visibility.Visible; lstDrag999.Visibility = Visibility.Visible; radDrag999.Visibility = Visibility.Visible; chkDrag999.Visibility = Visibility.Visible; } } }
int DownloadAndExtractZipFile() { str = CRMName; str = str + "_CRM"; //Retrives the Assembly of the Zip file. Assembly ass = Assembly.GetEntryAssembly(); #region Downloading ZipFile //Set the Variable. filename = str + ".zip"; //string strModPath = ""; #region Download Zip File using WCF FileTranserService //Download file using WCF FileTransferService try { //Create object of the HTTP Client. BasicHttpClient bhcFts = new BasicHttpClient(); //Open Client. clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService"); //Join the network. clientHttpFileTransfer.svcHTTPFileTransferServiceJoin(); //Create request to download File from Bootstrap. DownloadRequest request = new DownloadRequest(); //Providing the information of the file that needs to download. RemoteFileInfo rfi = new RemoteFileInfo(); request.FileName = filename; request.FolderWhereFileIsStored = "CRMs"; //Calling the WCF Function for downloading the File. rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(request); //Checking for Directory Existence. //if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs")); } destination = ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"); //Checking for File Existance. if (File.Exists((destination + "\\" + filename))) { File.Delete((destination + "\\" + filename)); } filePath = destination + "\\" + filename; System.IO.Stream inputStream = rfi.FileByteStream; using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write)) { int chunkSize = 2048; byte[] buffer = new byte[chunkSize]; do { // read bytes from input stream int bytesRead = inputStream.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) { //MessageBox.Show("Download Zip: " + ex.Message); VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); if (ex.InnerException != null) { //MessageBox.Show("Download Zip Inner Exception: " + ex.InnerException.Message); VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); } } #endregion #region Downloading using Web Client --------Commented //try //{ // Uri u = new Uri("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + "/VMukti/CRMs/" + filename); // if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"))) // { // Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMs")); // } // destination = ass.Location.Replace("VMukti.Presentation.exe", @"CRMs"); // if (!File.Exists(destination + "\\" + filename)) // { // WebClient wc = new WebClient(); // try // { // wc.DownloadFile(u, destination + "\\" + filename); // } // catch (Exception exp) // { // MessageBox.Show(exp.Message); // } // } //} //catch (Exception exp) //{ // MessageBox.Show("Down Load Error - " + exp.Message); //} #endregion #endregion #region Extracting //Code for Extracting the .zip file. try { //Checking for the Existance of the Directory. if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"CRMModules")); } str = CRMName; str = str + "_CRM"; Assembly ass2 = Assembly.GetEntryAssembly(); strModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"CRMModules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); //ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip(); //FastZip fz = new FastZip(); //if (!Directory.Exists(strModPath + "\\" + filename.Split('.')[0])) //{ try { //Extracting the zip file. fz.ExtractZip(destination + "\\" + filename, strModPath+"\\"+str, null); } catch (Exception exp) { //MessageBox.Show(exp.Message + " First Desgine Required CRM Using CRMDesginer"); VMuktiHelper.ExceptionHandler(exp, "DownloadAndExtractZipFile()", "CtlCRMContainer.xaml.cs"); } // } } catch (Exception exp) { VMuktiHelper.ExceptionHandler(exp, "DownloadAndExtractZipFile(Outer)", "CtlCRMContainer.xaml.cs"); return -1; } #endregion return 0; }