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; }
//dispatture function which is started from thread which is started from loadmodule function. public void dispMethLoadModule(object objModuleParams) { try { object[] obj = (object[])objModuleParams; #region Collaborative if (obj.Length == 3) // it is true than objModuleParams is having http uri, else it is of net.p2p { VMukti.Business.VMuktiGrid.ClsModule objModule = ClsModule.GetPodModule(this.ModuleID); #region Downloading ZipFile Uri zipFileURL = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + objModule.ZipFile); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files")); } string destination = ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"); if (!File.Exists(destination + "\\" + objModule.ZipFile)) { WebClient wc = new WebClient(); wc.DownloadFile(zipFileURL, destination + "\\" + objModule.ZipFile); } #endregion //if we add new identifiers for POD in a zip file u can find it over here and have to change accordingly #region Extracting string strModPath = ass.Location.Replace("VMukti.Presentation.exe", @"Modules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + objModule.ZipFile.Split('.')[0])) { fz.ExtractZip(destination + "\\" + objModule.ZipFile, strModPath, null); } string strXmlPath = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\configuration.xml"; if (File.Exists(strXmlPath)) { #region Parsing XML XmlParser xp = new XmlParser(); xp.Parse(strXmlPath); #endregion try { if (!string.IsNullOrEmpty(xp.xMain.SWFFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.SWFFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName); } } if (!string.IsNullOrEmpty(xp.xMain.TextFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.TextFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "dispMethLoadModule--copying swf n txt files", "Domains\\SuperNodeServiceDomain.cs"); } } #endregion #region Loading ReferencedAssemblies //DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath); DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0]); ShowDirectory(dirinfomodule); #region extracting imagefile string imagefilename = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\" + "Control\\" + objModule.ZipFile.Split('.')[0] + ".png"; if (File.Exists(imagefilename)) { BitmapImage objimage = new BitmapImage(); objimage.BeginInit(); objimage.UriSource = new Uri(imagefilename); objimage.EndInit(); imgPODIcon.BeginInit(); imgPODIcon.Source = objimage; imgPODIcon.EndInit(); } #endregion //following code will load bal and dal from reflaction in RAM for (int j = 0; j < al.Count; j++) { string[] arraysplit = al[j].ToString().Split('\\'); if (arraysplit[arraysplit.Length - 1].ToString() == objModule.AssemblyFile) { a = Assembly.LoadFrom(al[j].ToString()); AssemblyName[] an = a.GetReferencedAssemblies(); for (int alcount = 0; alcount < al.Count; alcount++) { string strsplit = al[alcount].ToString(); string[] strold = strsplit.Split('\\'); string strnew = strold[strold.Length - 1].Substring(0, strold[strold.Length - 1].Length - 4); for (int asscount = 0; asscount < an.Length; asscount++) { if (an[asscount].Name == strnew) { Assembly assbal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[alcount].ToString()).GetName()); AssemblyName[] anbal = assbal.GetReferencedAssemblies(); for (int andal = 0; andal < al.Count; andal++) { string strsplitdal = al[andal].ToString(); string[] strolddal = strsplitdal.Split('\\'); string strnewdal = strolddal[strolddal.Length - 1].Substring(0, strolddal[strolddal.Length - 1].Length - 4); for (int asscountdal = 0; asscountdal < anbal.Length; asscountdal++) { if (anbal[asscountdal].Name == strnewdal) { Assembly assdal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[andal].ToString()).GetName()); } } } } } } Type[] t1 = a.GetTypes(); #region CreatingObject for (int k = 0; k < t1.Length; k++) { if (t1[k].Name == objModule.ClassName) { try { ConstructorInfo[] ci = t1[k].GetConstructors(); for (int constcount = 0; constcount < ci.Length; constcount++) { ParameterInfo[] pi = ci[constcount].GetParameters(); if (pi.Length == 4) { //if module is collaborative, it will be haveing more than one (nearly 4) parameters and so it will come here and will create object with required parameter. if (pi[0].ParameterType.Name == "PeerType") { object[] objArg = new object[4]; objArg[0] = VMuktiInfo.CurrentPeer.CurrPeerType; objArg[1] = obj[0].ToString(); objArg[2] = obj[1]; if (_strFromWhere == "fromOtherPeer") { objArg[3] = "Guest"; } else if (_strFromWhere == "fromLeftPane" || _strFromWhere == "fromDatabase") { objArg[3] = "Host"; } //Object of module will be created here by reflaction object obj1 = Activator.CreateInstance(t1[k], BindingFlags.CreateInstance, null, objArg, new System.Globalization.CultureInfo("en-US")); grdBody.Tag = t1[k].ToString(); grdBody.Children.Remove(animImage); grdBody.Children.Add((UIElement)obj1); if (!this.IsTwoPanel) { #region changes for pod resize ItemsControl objItem = (ItemsControl)(this.Parent); if (objItem.Name != "TopPanelContainer" && objItem.Name != "BottomPanelContainer") { ColumnDefinitionCollection ColCollection = ((Grid)(objItem.Parent)).ColumnDefinitions; int colNo = Convert.ToInt32(objItem.Tag) - 1; GridLength WidthToBeSet = new GridLength((((UserControl)obj1).Width) / 100, GridUnitType.Star); double previousActualWidth = -1; if (ColCollection[colNo].Width.Value > 100) { previousActualWidth = (ColCollection[colNo].Width.Value / 100); } else { previousActualWidth = ColCollection[colNo].Width.Value; string strPAW = previousActualWidth.ToString(); int intPAW = Convert.ToInt32(previousActualWidth); switch (intPAW) { case 1: previousActualWidth = 4; break; case 2: previousActualWidth = 4; break; case 3: previousActualWidth = 4; break; case 4: previousActualWidth = 4; break; case 5: previousActualWidth = 5.5; break; case 6: previousActualWidth = 6.5; break; default: previousActualWidth = 7; break; } } if (previousActualWidth < WidthToBeSet.Value) { ColCollection[1].Width = new GridLength(0, GridUnitType.Star); ColCollection[2].Width = new GridLength(0, GridUnitType.Star); ColCollection[0].Width = new GridLength(0, GridUnitType.Star); switch (colNo) { case 0: ColCollection[1].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 1: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[1].Width = new GridLength(1, GridUnitType.Star); break; } int objint = Convert.ToInt32(WidthToBeSet.Value); switch (objint) { case 1: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 3: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 4: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 5: ColCollection[colNo].Width = new GridLength(2, GridUnitType.Star); break; case 6: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; default: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; } } } #endregion } break; } } else { object obj1 = Activator.CreateInstance(t1[k]); ((UserControl)obj1).SetValue(Canvas.LeftProperty, 0.0); ((UserControl)obj1).SetValue(Canvas.TopProperty, 0.0); grdBody.Tag = t1[k].ToString(); grdBody.Children.Remove(animImage); grdBody.Children.Add((UIElement)obj1); if (!this.IsTwoPanel) { #region changes for pod resize ItemsControl objItem = (ItemsControl)(this.Parent); if (objItem.Name != "TopPanelContainer" && objItem.Name != "BottomPanelContainer") { ColumnDefinitionCollection ColCollection = ((Grid)(objItem.Parent)).ColumnDefinitions; int colNo = Convert.ToInt32(objItem.Tag) - 1; GridLength WidthToBeSet = new GridLength((((UserControl)obj1).Width) / 100, GridUnitType.Star); double previousActualWidth = -1; if (ColCollection[colNo].Width.Value > 100) { previousActualWidth = (ColCollection[colNo].Width.Value / 100); } else { previousActualWidth = ColCollection[colNo].Width.Value; string strPAW = previousActualWidth.ToString(); int intPAW = Convert.ToInt32(previousActualWidth); switch (intPAW) { case 1: previousActualWidth = 4; break; case 2: previousActualWidth = 4; break; case 3: previousActualWidth = 4; break; case 4: previousActualWidth = 4; break; case 5: previousActualWidth = 5.5; break; case 6: previousActualWidth = 6.5; break; default: previousActualWidth = 7; break; } } if (previousActualWidth < WidthToBeSet.Value) { ColCollection[1].Width = new GridLength(0, GridUnitType.Star); ColCollection[2].Width = new GridLength(0, GridUnitType.Star); ColCollection[0].Width = new GridLength(0, GridUnitType.Star); switch (colNo) { case 0: ColCollection[1].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 1: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[1].Width = new GridLength(1, GridUnitType.Star); break; } int objint = Convert.ToInt32(WidthToBeSet.Value); switch (objint) { case 1: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 3: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 4: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 5: ColCollection[colNo].Width = new GridLength(2, GridUnitType.Star); break; case 6: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; default: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; } } } #endregion } break; } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CreatingObject--5", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); } break; } } #endregion } } #endregion } #endregion #region NonCollaborative //it will create an object of p2p node else { VMukti.Business.VMuktiGrid.ClsModule objModule = ClsModule.GetPodModule(this.ModuleID); #region Downloading ZipFile Uri zipFileURL = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + objModule.ZipFile); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files")); } string destination = ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"); if (!File.Exists(destination + "\\" + objModule.ZipFile)) { WebClient wc = new WebClient(); wc.DownloadFile(zipFileURL, destination + "\\" + objModule.ZipFile); } #endregion #region Extracting string strModPath = ass.Location.Replace("VMukti.Presentation.exe", @"Modules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + objModule.ZipFile.Split('.')[0])) { fz.ExtractZip(destination + "\\" + objModule.ZipFile, strModPath, null); } string strXmlPath = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\configuration.xml"; if (File.Exists(strXmlPath)) { #region Parsing XML XmlParser xp = new XmlParser(); xp.Parse(strXmlPath); #endregion try { if (!string.IsNullOrEmpty(xp.xMain.SWFFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.SWFFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName); } } if (!string.IsNullOrEmpty(xp.xMain.TextFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.TextFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "dispMethLoadModule-NonCol--copying swf n txt files", "Domains\\SuperNodeServiceDomain.cs"); } } #endregion #region Loading ReferencedAssemblies DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0]); ShowDirectory(dirinfomodule); #region extracting imagefile string imagefilename = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\" + "Control\\" + objModule.ZipFile.Split('.')[0] + ".png"; if (File.Exists(imagefilename)) { BitmapImage objimage = new BitmapImage(); objimage.BeginInit(); objimage.UriSource = new Uri(imagefilename); objimage.EndInit(); imgPODIcon.BeginInit(); imgPODIcon.Source = objimage; imgPODIcon.EndInit(); } #endregion for (int j = 0; j < al.Count; j++) { string[] arraysplit = al[j].ToString().Split('\\'); if (arraysplit[arraysplit.Length - 1].ToString() == objModule.AssemblyFile) { a = Assembly.LoadFrom(al[j].ToString()); AssemblyName[] an = a.GetReferencedAssemblies(); for (int alcount = 0; alcount < al.Count; alcount++) { string strsplit = al[alcount].ToString(); string[] strold = strsplit.Split('\\'); string strnew = strold[strold.Length - 1].Substring(0, strold[strold.Length - 1].Length - 4); for (int asscount = 0; asscount < an.Length; asscount++) { if (an[asscount].Name == strnew) { Assembly assbal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[alcount].ToString()).GetName()); AssemblyName[] anbal = assbal.GetReferencedAssemblies(); for (int andal = 0; andal < al.Count; andal++) { string strsplitdal = al[andal].ToString(); string[] strolddal = strsplitdal.Split('\\'); string strnewdal = strolddal[strolddal.Length - 1].Substring(0, strolddal[strolddal.Length - 1].Length - 4); for (int asscountdal = 0; asscountdal < anbal.Length; asscountdal++) { if (anbal[asscountdal].Name == strnewdal) { Assembly assdal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[andal].ToString()).GetName()); } } } } } } Type[] t1 = a.GetTypes(); #region CreatingObject for (int k = 0; k < t1.Length; k++) { if (t1[k].Name == objModule.ClassName) { try { object[] objArg = new object[1]; objArg[0] = obj[0]; object obj1 = Activator.CreateInstance(t1[k], objArg); ((UserControl)obj1).SetValue(Canvas.LeftProperty, 0.0); ((UserControl)obj1).SetValue(Canvas.TopProperty, 0.0); grdBody.Tag = t1[k].ToString(); grdBody.Children.Remove(animImage); grdBody.Children.Add((UIElement)obj1); if (!this.IsTwoPanel) { #region changes for pod resize ItemsControl objItem = (ItemsControl)(this.Parent); ColumnDefinitionCollection ColCollection = ((Grid)(objItem.Parent)).ColumnDefinitions; int colNo = Convert.ToInt32(objItem.Tag) - 1; GridLength WidthToBeSet = new GridLength((((UserControl)obj1).Width) / 100, GridUnitType.Star); double previousActualWidth = -1; if (ColCollection[colNo].Width.Value > 100) { previousActualWidth = (ColCollection[colNo].Width.Value / 100); } else { previousActualWidth = ColCollection[colNo].Width.Value; string strPAW = previousActualWidth.ToString(); int intPAW = Convert.ToInt32(previousActualWidth); switch (intPAW) { case 1: previousActualWidth = 4; break; case 2: previousActualWidth = 4; break; case 3: previousActualWidth = 4; break; case 4: previousActualWidth = 4; break; case 5: previousActualWidth = 5.5; break; case 6: previousActualWidth = 6.5; break; default: previousActualWidth = 7; break; } } if (previousActualWidth < WidthToBeSet.Value) { ColCollection[1].Width = new GridLength(0, GridUnitType.Star); ColCollection[2].Width = new GridLength(0, GridUnitType.Star); ColCollection[0].Width = new GridLength(0, GridUnitType.Star); switch (colNo) { case 0: ColCollection[1].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 1: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[2].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[0].Width = new GridLength(1, GridUnitType.Star); ColCollection[1].Width = new GridLength(1, GridUnitType.Star); break; } int objint = Convert.ToInt32(WidthToBeSet.Value); switch (objint) { case 1: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 2: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 3: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 4: ColCollection[colNo].Width = new GridLength(1, GridUnitType.Star); break; case 5: ColCollection[colNo].Width = new GridLength(2, GridUnitType.Star); break; case 6: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; default: ColCollection[colNo].Width = new GridLength(2.5, GridUnitType.Star); break; } } #endregion } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CreatingObject--7", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); grdBody.Children.Add(new UIElement()); } } } #endregion } } #endregion } #endregion al.Clear(); //this part of the code is for infoming back the user who droped this user that module is loaded so that u can now show the user in ur buddy list. //if (_objPageInfo != null) //{ // clsBuddyRetPageInfo objBuddyRetPageInfo = new clsBuddyRetPageInfo(); // List<clsBuddyRetTabInfo> lstBuddyRetTabInfo = new List<clsBuddyRetTabInfo>(); // List<clsBuddyRetPodInfo> lstBuddyRetPodInfo = new List<clsBuddyRetPodInfo>(); // objBuddyRetPageInfo.intOwnerID = _objPageInfo.intOwnerID; // objBuddyRetPageInfo.intOwnerPageIndex = _objPageInfo.intOwnerPageIndex; // objBuddyRetPageInfo.intPageID = _objPageInfo.intPageID; // objBuddyRetPageInfo.strDropType = _objPageInfo.strDropType; // int ownerindex = ((VMuktiGrid.ctlTab.TabItem)((ctlGrid)((Grid)((ItemsControl)this.Parent).Parent).Parent).Parent).OwnerTabIndex; // for (int i = 0; i < _objPageInfo.objaTabs.Length; i++) // { // if (ownerindex == _objPageInfo.objaTabs[i].intOwnerTabIndex) // { // int lstBuddyRetTabInfoCount = lstBuddyRetTabInfo.Count - 1; // lstBuddyRetTabInfo.Add(new clsBuddyRetTabInfo()); // lstBuddyRetTabInfo[lstBuddyRetTabInfoCount].intOwnerTabIndex = _objPageInfo.objaTabs[i].intOwnerTabIndex; // lstBuddyRetTabInfo[lstBuddyRetTabInfoCount].intTabID = _objPageInfo.objaTabs[i].intTabID; // for (int j = 0; j < _objPageInfo.objaTabs[i].objaPods.Length; j++) // { // if (this.OwnerPodIndex == _objPageInfo.objaTabs[i].objaPods[j].intOwnerPodIndex) // { // lstBuddyRetPodInfo.Add(new clsBuddyRetPodInfo()); // lstBuddyRetPodInfo[lstBuddyRetTabInfoCount].intColumnNumber = _objPageInfo.objaTabs[i].objaPods[j].intColumnNumber; // lstBuddyRetPodInfo[lstBuddyRetTabInfoCount].intModuleId = _objPageInfo.objaTabs[i].objaPods[j].intModuleId; // lstBuddyRetPodInfo[lstBuddyRetTabInfoCount].intOwnerPodIndex = _objPageInfo.objaTabs[i].objaPods[j].intOwnerPodIndex; // lstBuddyRetPodInfo[lstBuddyRetTabInfoCount].straPodBuddies = _objPageInfo.objaTabs[i].objaPods[j].straPodBuddies; // } // } // lstBuddyRetTabInfo[lstBuddyRetTabInfoCount].objaPods = lstBuddyRetPodInfo.ToArray(); // } // } // objBuddyRetPageInfo.objaTabs = lstBuddyRetTabInfo.ToArray(); // objBuddyRetPageInfo.strFrom = _objPageInfo.strTo; // objBuddyRetPageInfo.strTo = _objPageInfo.strFrom; // objBuddyRetPageInfo.strMsg = "MODULE_LOADED"; //} } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "dispMethoadModule()", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); } }
void bwDownloadZips_DoWork(object sender, DoWorkEventArgs e) { try { ClsModuleCollection cmc = (ClsModuleCollection)e.Argument; Assembly ass = Assembly.GetAssembly(typeof(pgHome)); for (int i = 0; i < cmc.Count; i++) { #region Downloading ZipFile string filename = cmc[i].ZipFile; Uri u = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + filename); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files")); } string destination = ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"); try { if (!File.Exists(destination + "\\" + filename)) { WebClient wc = new WebClient(); wc.DownloadFile(u, destination + "\\" + filename); } #endregion #region Extracting string strModPath = ass.Location.Replace("VMukti.Presentation.exe", @"Modules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + filename.Split('.')[0])) { fz.ExtractZip(destination + "\\" + filename, strModPath, null); } string strXmlPath = strModPath + "\\" + filename.Split('.')[0] + "\\Control\\configuration.xml"; if (File.Exists(strXmlPath)) { #region Parsing XML XmlParser xp = new XmlParser(); xp.Parse(strXmlPath); #endregion try { if (!string.IsNullOrEmpty(xp.xMain.SWFFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + filename.Split('.')[0] + "\\Control\\" + xp.xMain.SWFFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName); } } if (!string.IsNullOrEmpty(xp.xMain.TextFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + filename.Split('.')[0] + "\\Control\\" + xp.xMain.TextFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "bwDownloadZips_DoWork--copying swf n txt files", "Domains\\SuperNodeServiceDomain.cs"); } } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "bwDownloadZips_DoWork--File " + filename + " Not Found", "pgHome.xaml.cs"); } #endregion } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "beDownloadZips_DoWork()", "pgHome.xaml.cs"); } }
public void LoadPod4MultipleBuddies(object objModuleParams) { try { object[] obj = (object[])objModuleParams; #region Collaborative if (obj.Length == 3) { VMukti.Business.VMuktiGrid.ClsModule objModule = ClsModule.GetPodModule(this.ModuleID); #region Downloading ZipFile Uri zipFileURL = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + objModule.ZipFile); if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"))) { Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files")); } string destination = ass.Location.Replace("VMukti.Presentation.exe", @"Zip Files"); if (!File.Exists(destination + "\\" + objModule.ZipFile)) { WebClient wc = new WebClient(); wc.DownloadFile(zipFileURL, destination + "\\" + objModule.ZipFile); } #endregion #region Extracting string strModPath = ass.Location.Replace("VMukti.Presentation.exe", @"Modules"); VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + objModule.ZipFile.Split('.')[0])) { fz.ExtractZip(destination + "\\" + objModule.ZipFile, strModPath, null); } string strXmlPath = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\configuration.xml"; if (File.Exists(strXmlPath)) { #region Parsing XML XmlParser xp = new XmlParser(); xp.Parse(strXmlPath); #endregion try { if (!string.IsNullOrEmpty(xp.xMain.SWFFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.SWFFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.SWFFileName); } } if (!string.IsNullOrEmpty(xp.xMain.TextFileName)) { if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName)) { FileInfo fi = new FileInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\Control\\" + xp.xMain.TextFileName); fi.CopyTo(AppDomain.CurrentDomain.BaseDirectory + xp.xMain.TextFileName); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "LoadPod4MultipleBuddies--copying swf n txt files", "Domains\\SuperNodeServiceDomain.cs"); } } #endregion #region Loading ReferencedAssemblies DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath + "\\" + objModule.ZipFile.Split('.')[0]); ShowDirectory(dirinfomodule); #region extracting imagefile string imagefilename = strModPath + "\\" + objModule.ZipFile.Split('.')[0] + "\\" + "Control\\" + objModule.ZipFile.Split('.')[0] + ".png"; if (File.Exists(imagefilename)) { BitmapImage objimage = new BitmapImage(); objimage.BeginInit(); objimage.UriSource = new Uri(imagefilename); objimage.EndInit(); imgPODIcon.BeginInit(); imgPODIcon.Source = objimage; imgPODIcon.EndInit(); } #endregion for (int j = 0; j < al.Count; j++) { string[] arraysplit = al[j].ToString().Split('\\'); if (arraysplit[arraysplit.Length - 1].ToString() == objModule.AssemblyFile) { a = Assembly.LoadFrom(al[j].ToString()); AssemblyName[] an = a.GetReferencedAssemblies(); for (int alcount = 0; alcount < al.Count; alcount++) { string strsplit = al[alcount].ToString(); string[] strold = strsplit.Split('\\'); string strnew = strold[strold.Length - 1].Substring(0, strold[strold.Length - 1].Length - 4); for (int asscount = 0; asscount < an.Length; asscount++) { if (an[asscount].Name == strnew) { Assembly assbal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[alcount].ToString()).GetName()); AssemblyName[] anbal = assbal.GetReferencedAssemblies(); for (int andal = 0; andal < al.Count; andal++) { string strsplitdal = al[andal].ToString(); string[] strolddal = strsplitdal.Split('\\'); string strnewdal = strolddal[strolddal.Length - 1].Substring(0, strolddal[strolddal.Length - 1].Length - 4); for (int asscountdal = 0; asscountdal < anbal.Length; asscountdal++) { if (anbal[asscountdal].Name == strnewdal) { Assembly assdal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[andal].ToString()).GetName()); } } } } } } Type[] t1 = a.GetTypes(); #region CreatingObject for (int k = 0; k < t1.Length; k++) { if (t1[k].Name == objModule.ClassName) { try { ConstructorInfo[] ci = t1[k].GetConstructors(); for (int constcount = 0; constcount < ci.Length; constcount++) { ParameterInfo[] pi = ci[constcount].GetParameters(); if (pi.Length == 4) { if (pi[0].ParameterType.Name == "PeerType") { object[] objArg = new object[4]; objArg[0] = VMuktiInfo.CurrentPeer.CurrPeerType; objArg[1] = obj[0].ToString(); objArg[2] = obj[1]; if (_strFromWhere == "fromOtherPeer") { objArg[3] = "Guest"; } else if (_strFromWhere == "fromLeftPane" || _strFromWhere == "fromDatabase") { objArg[3] = "Host"; } object obj1 = Activator.CreateInstance(t1[k], BindingFlags.CreateInstance, null, objArg, new System.Globalization.CultureInfo("en-US")); grdBody.Tag = t1[k].ToString(); grdBody.Children.Remove(animImage); grdBody.Children.Add((UIElement)obj1); break; } } else { object obj1 = Activator.CreateInstance(t1[k]); ((UserControl)obj1).SetValue(Canvas.LeftProperty, 0.0); ((UserControl)obj1).SetValue(Canvas.TopProperty, 0.0); grdBody.Tag = t1[k].ToString(); grdBody.Children.Remove(animImage); grdBody.Children.Add((UIElement)obj1); break; } } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "CreatingObject--5", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); } } } #endregion } } #endregion } #endregion al.Clear(); #region dhaval if (_strFromWhere == "fromPeer") { for (int onlineBuddyCnt = 0; onlineBuddyCnt < onlineBuddy.Count; onlineBuddyCnt++) { this.AddBuddy(onlineBuddy[onlineBuddyCnt]); } } #endregion dhaval if (_strFromWhere != "fromPeer") { InformMultipleBuddy(); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "PageThread()", "Controls\\VMuktiGrid\\Grid\\ctlPOD.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); }
void DBReports() { try { ClsWidgetsCollection objGetAll = ClsWidgetsCollection.GetAllWidgets(); foreach (ClsWidgets wid in objGetAll) { if (wid.ModuleTitle.Contains("Report-")) { TabItem tbItemRpt = new TabItem(); tbItemRpt.Height = 40; tbItemRpt.Header = wid.ModuleTitle.Replace("Report-", "").Trim(); try { #region Downloading ZipFile string filename = wid.ZipFile; Uri u = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + filename); if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory+ "Zip Files")) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "Zip Files"); } string destination = AppDomain.CurrentDomain.BaseDirectory + "Zip Files"; if (!File.Exists(destination + "\\" + filename)) { WebClient wc = new WebClient(); wc.DownloadFile(u, destination + "\\" + filename); } #endregion #region Extracting string strModPath = AppDomain.CurrentDomain.BaseDirectory + "Modules"; VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + filename.Split('.')[0])) { fz.ExtractZip(destination + "\\" + filename, strModPath, null); } #endregion #region Loading ReferencedAssemblies DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath + "\\" + wid.ZipFile.Split('.')[0]); ShowDirectory(dirinfomodule); for (int j = 0; j < al.Count; j++) { string[] arraysplit = al[j].ToString().Split('\\'); if (arraysplit[arraysplit.Length - 1].ToString() == wid.AssemblyFile) { a = Assembly.LoadFrom(al[j].ToString()); AssemblyName[] an = a.GetReferencedAssemblies(); for (int alcount = 0; alcount < al.Count; alcount++) { string strsplit = al[alcount].ToString(); string[] strold = strsplit.Split('\\'); string strnew = strold[strold.Length - 1].Substring(0, strold[strold.Length - 1].Length - 4); for (int asscount = 0; asscount < an.Length; asscount++) { if (an[asscount].Name == strnew) { Assembly assbal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[alcount].ToString()).GetName()); AssemblyName[] anbal = assbal.GetReferencedAssemblies(); for (int andal = 0; andal < al.Count; andal++) { string strsplitdal = al[andal].ToString(); string[] strolddal = strsplitdal.Split('\\'); string strnewdal = strolddal[strolddal.Length - 1].Substring(0, strolddal[strolddal.Length - 1].Length - 4); for (int asscountdal = 0; asscountdal < anbal.Length; asscountdal++) { if (anbal[asscountdal].Name == strnewdal) { Assembly assdal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[andal].ToString()).GetName()); } } } } } } Type[] t1 = a.GetTypes(); #region CreatingObject for (int k = 0; k < t1.Length; k++) { if (t1[k].Name == wid.ClassName) { try { object[] objArg = new object[1]; objArg[0] = new ModulePermissions[] { ModulePermissions.Add, ModulePermissions.Delete, ModulePermissions.Edit, ModulePermissions.View }; object obj1 = Activator.CreateInstance(t1[k], objArg); tbItemRpt.Content = obj1; } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CreatingObject--7", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); } } } #endregion } } #endregion } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "DBReports()--creating object", "ctlDashBoardContainer.xaml.cs"); } tbItemRpt.Tag = wid; tbCnt.Items.Add(tbItemRpt); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DBReports", "ctlDashBoardContainer.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; }
void DBReports() { try { ClsWidgetsCollection objGetAll = ClsWidgetsCollection.GetAllWidgets(); foreach (ClsWidgets wid in objGetAll) { if (wid.ModuleTitle.Contains("Report-")) { TabItem tbItemRpt = new TabItem(); tbItemRpt.Height = 40; tbItemRpt.Header = wid.ModuleTitle.Replace("Report-", "").Trim(); try { #region Downloading ZipFile string filename = wid.ZipFile; Uri u = new Uri(VMuktiAPI.VMuktiInfo.ZipFileDownloadLink + filename); if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "Zip Files")) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "Zip Files"); } string destination = AppDomain.CurrentDomain.BaseDirectory + "Zip Files"; if (!File.Exists(destination + "\\" + filename)) { WebClient wc = new WebClient(); wc.DownloadFile(u, destination + "\\" + filename); } #endregion #region Extracting string strModPath = AppDomain.CurrentDomain.BaseDirectory + "Modules"; VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip(); if (!Directory.Exists(strModPath + "\\" + filename.Split('.')[0])) { fz.ExtractZip(destination + "\\" + filename, strModPath, null); } #endregion #region Loading ReferencedAssemblies DirectoryInfo dirinfomodule = new DirectoryInfo(strModPath + "\\" + wid.ZipFile.Split('.')[0]); ShowDirectory(dirinfomodule); for (int j = 0; j < al.Count; j++) { string[] arraysplit = al[j].ToString().Split('\\'); if (arraysplit[arraysplit.Length - 1].ToString() == wid.AssemblyFile) { a = Assembly.LoadFrom(al[j].ToString()); AssemblyName[] an = a.GetReferencedAssemblies(); for (int alcount = 0; alcount < al.Count; alcount++) { string strsplit = al[alcount].ToString(); string[] strold = strsplit.Split('\\'); string strnew = strold[strold.Length - 1].Substring(0, strold[strold.Length - 1].Length - 4); for (int asscount = 0; asscount < an.Length; asscount++) { if (an[asscount].Name == strnew) { Assembly assbal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[alcount].ToString()).GetName()); AssemblyName[] anbal = assbal.GetReferencedAssemblies(); for (int andal = 0; andal < al.Count; andal++) { string strsplitdal = al[andal].ToString(); string[] strolddal = strsplitdal.Split('\\'); string strnewdal = strolddal[strolddal.Length - 1].Substring(0, strolddal[strolddal.Length - 1].Length - 4); for (int asscountdal = 0; asscountdal < anbal.Length; asscountdal++) { if (anbal[asscountdal].Name == strnewdal) { Assembly assdal = System.AppDomain.CurrentDomain.Load(System.Reflection.Assembly.LoadFrom(al[andal].ToString()).GetName()); } } } } } } Type[] t1 = a.GetTypes(); #region CreatingObject for (int k = 0; k < t1.Length; k++) { if (t1[k].Name == wid.ClassName) { try { object[] objArg = new object[1]; objArg[0] = new ModulePermissions[] { ModulePermissions.Add, ModulePermissions.Delete, ModulePermissions.Edit, ModulePermissions.View }; object obj1 = Activator.CreateInstance(t1[k], objArg); tbItemRpt.Content = obj1; } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CreatingObject--7", "Controls\\VMuktiGrid\\Grid\\ctlPOD.xaml.cs"); } } } #endregion } } #endregion } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "DBReports()--creating object", "ctlDashBoardContainer.xaml.cs"); } tbItemRpt.Tag = wid; tbCnt.Items.Add(tbItemRpt); } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DBReports", "ctlDashBoardContainer.xaml.cs"); } }