Пример #1
0
        public ClsModuleLogic GetPodModule(int intModId)
        {
            ClsModuleLogic obj = new ClsModuleLogic();

            if (bool.Parse(VMuktiAPI.VMuktiInfo.Port80) && VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType != PeerType.BootStrap)
            {
                DataSet ds = null;

                try
                {
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                catch (System.ServiceModel.EndpointNotFoundException e)
                {
                    VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");

                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                catch (System.ServiceModel.CommunicationException e)
                {
                    VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");
                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                if (!obj.MapData(ds.Tables[0])) obj = null;
            }
            else
            {

                if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp)
                {
                    DataSet ds = null;

                    try
                    {
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    catch (System.ServiceModel.EndpointNotFoundException e)
                    {
                        VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");

                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    catch (System.ServiceModel.CommunicationException e)
                    {
                        VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");
                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    if (!obj.MapData(ds.Tables[0])) obj = null;

                }
                else
                {

                    DataSet ds = new ClsModuleDataService().Get_PodModule(intModId);
                    if (!obj.MapData(ds.Tables[0])) obj = null;
                }
            }
            return obj;
        }
        void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                #region cheking

               

                if (ofd.FileName == null || ofd.FileName == "")
                {
                    System.Windows.MessageBox.Show("Browse the File to Upload");
                    txtUpload.Focus();
                    return;

                }
                if (cmbAssembly.SelectedItem == null)
                {
                    System.Windows.MessageBox.Show("Select the Assembly File");
                    cmbAssembly.Focus();
                    return;
                }
                if (cmbClass.SelectedItem == null)
                {
                    System.Windows.MessageBox.Show("Select the Class Name");
                    cmbClass.Focus();
                    return;
                }
                if (txtModule.Text == "" || txtModule.Text == null)
                {
                    System.Windows.MessageBox.Show("Enter Module Name");
                    txtModule.Focus();
                    return;
                }

                if (!new ClsModuleLogic().ModuleExists(txtModule.Text))
                {
                    System.Windows.MessageBox.Show("Specify another module name");
                    txtModule.Focus();
                    return;
                }
                
                if (!IsVersionValid())
                {
                    System.Windows.MessageBox.Show("Enter Valid Version Number");
                    txtVersion.Focus();
                    return;
                }

                #endregion

                try
                {

                    DirectoryInfo diZip = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Zip Files");

                    File.Copy(ofd.FileName, diZip.FullName + "\\" + ofd.SafeFileName);


                    DirectoryInfo diModule = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Modules");
                    VMukti.ZipUnzip.Zip.FastZip fz = new VMukti.ZipUnzip.Zip.FastZip();
                    if (!Directory.Exists(diModule.FullName + "\\" + ofd.SafeFileName.Split('.')[0]))
                    {
                        fz.ExtractZip(diZip.FullName + "\\" + ofd.SafeFileName, diModule.FullName, null);
                    }


                    //    Upload the Zip file To bs 

                    System.IO.FileStream stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                    RemoteFileInfo rfiUpload = new RemoteFileInfo();
                    rfiUpload.FileName = ofd.SafeFileName;
                    rfiUpload.FolderNameToStore = "";
                    rfiUpload.FileByteStream = stream;
                    rfiUpload.Length = stream.Length;
                    clientHttpChannelFileTransfer.svcHTTPFileTransferServiceUploadFile(rfiUpload);
                    stream.Flush();
                    stream.Close();
                    FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    rfiUpload.FileByteStream = fs;
                    clientHttpChannelFileTransfer.svcHTTPFileTransferServiceUploadFileToInstallationDirectory(rfiUpload);
                    fs.Flush();
                    fs.Close();
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("The Zip File is already uploaded please select another File");
                    VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSubmit_Click()", "Controls\\CtlUploadModule.xaml.cs");
                    return;
                }

                ClsModuleLogic cml = new ClsModuleLogic();
                TextRange tr = new TextRange(rtbDescription.Document.ContentStart, rtbDescription.Document.ContentEnd);


                #region Creating byte array of imagefile
                List<byte[]> ImageByte = new List<byte[]>();

                if (!string.IsNullOrEmpty(txtModuleImage.Text))
                {
                    byte[] b = SetImage(txtModuleImage.Text);
                    if (b != null)
                    {
                        ImageByte.Add(b);
                    }
                    else
                    {
                        b = SetImage(AppDomain.CurrentDomain.BaseDirectory + "\\Skins\\Images\\Help.png");
                        if (b != null)
                        {
                            ImageByte.Add(b);
                        }
                    }
                }
                else
                {
                    byte[] b = SetImage(AppDomain.CurrentDomain.BaseDirectory + "\\Skins\\Images\\Help.png");
                    if (b != null)
                    {
                        ImageByte.Add(b);
                    }
                }
                #endregion

                int intModId = -1;

                intModId = cml.AddModule(-1, txtModule.Text, txtVersion.Text, tr.Text, ((ComboBoxItem)cmbAssembly.SelectedItem).Content.ToString(), ((ComboBoxItem)cmbClass.SelectedItem).Content.ToString(), txtZip.Text, 1, ckbCollaborate.IsChecked.Value, ckbAuthentication.IsChecked.Value, ImageByte[0]);

                if (intModId == -1)
                {
                    System.Windows.MessageBox.Show("Report this error to your administrator");
                    return;
                }
                    ClsPermissionLogic cpl = new ClsPermissionLogic();

                    foreach (object chk in grid1.Children)
                    {
                        if (chk.GetType() == typeof(System.Windows.Controls.CheckBox) && ((System.Windows.Controls.CheckBox)chk).Tag != null)
                        {
                            int i = 0;
                            string[] strPermission = (((System.Windows.Controls.CheckBox)chk).Tag).ToString().Split(',');

                            for (i = 0; i < objModulePermissions.Count; i++)
                            {
                                if (objModulePermissions[i].PermissionName == strPermission[0])
                                {
                                    break;
                                }
                            }
                            if (i == objModulePermissions.Count)
                            {
                                objModulePermissions.Add(new clsModulePermission(intModId, cpl.Add_Permission(-1, intModId, strPermission[0], int.Parse(strPermission[1])), strPermission[0], int.Parse(strPermission[1])));
                            }

                            if (((System.Windows.Controls.CheckBox)chk).IsChecked == true)
                            {
                                for (int j = 0; j < objModulePermissions.Count; j++)
                                {
                                    if (objModulePermissions[j].PermissionName == strPermission[0])
                                    {
                                        cpl.Add_ModulePermission(objModulePermissions[j].PermissionID, int.Parse(strPermission[2]));
                                        ((System.Windows.Controls.CheckBox)chk).IsChecked = false;

                                        break;
                                    }
                                }
                            }
                        }
                    }

                    System.Windows.MessageBox.Show("Module Uploaded");

                    txtUpload.Clear();
                    txtZip.Clear();
                    cmbAssembly.Items.Clear();
                    cmbClass.Items.Clear();
                    txtModule.Clear();
                    txtVersion.Clear();
                    ckbCollaborate.IsChecked = false;
                    rtbDescription.SelectAll();
                    rtbDescription.Selection.Text = "";
                    ckbAuthentication.IsChecked = false;
                    txtModuleImage.Text = "";

                    if (grid1.Children.Count > 0)
                    {
                        grid1.Children.Clear();
                    }

                    objModulePermissions.Clear();
                

            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "btnSubmit_Click()--1", "Controls\\CtlUploadModule.xaml.cs");
            }
        }
Пример #3
0
        public ClsModuleLogic GetPodModule(int intModId)
        {
            ClsModuleLogic obj = new ClsModuleLogic();

            if (bool.Parse(VMuktiAPI.VMuktiInfo.Port80) && VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType != PeerType.BootStrap)
            {
                DataSet ds = null;

                try
                {
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                catch (System.ServiceModel.EndpointNotFoundException e)
                {
                    VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");

                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                catch (System.ServiceModel.CommunicationException e)
                {
                    VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");
                    VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                    ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                }
                if (!obj.MapData(ds.Tables[0]))
                {
                    obj = null;
                }
            }
            else
            {
                if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp)
                {
                    DataSet ds = null;

                    try
                    {
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    catch (System.ServiceModel.EndpointNotFoundException e)
                    {
                        VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");

                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    catch (System.ServiceModel.CommunicationException e)
                    {
                        VMuktiHelper.ExceptionHandler(e, "GetPodModule(int intModId)", "ClsModuleLogic.cs");
                        VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                        ds = VMukti.Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ID,ModuleName,IsCollaborative,ZipFile,AssemblyFile from Module where ID=" + intModId + "order by ModuleName").dsInfo;
                    }
                    if (!obj.MapData(ds.Tables[0]))
                    {
                        obj = null;
                    }
                }
                else
                {
                    DataSet ds = new ClsModuleDataService().Get_PodModule(intModId);
                    if (!obj.MapData(ds.Tables[0]))
                    {
                        obj = null;
                    }
                }
            }
            return(obj);
        }