Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
0
        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");
            }
        }
Exemplo n.º 3
0
        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");
            }
        }