Ejemplo n.º 1
0
        public bool DocumentShareStart(string strPath,out MessageObject msg)
        {
            msg = null;
            try
            {
                m_sharedFilePath = strPath;
                if(UploadDocument())
                {
                    if(OnStatusUpdateFunction !=null)
                        OnStatusUpdateFunction(DOCSHARING_REQUEST_MSG);
                    NetworkManager networkMngr = NetworkManager.getInstance();
                    WebMeeting.Common.DocumentSharing message = new WebMeeting.Common.DocumentSharing();
                    message.SenderID = networkMngr.profile.ClientId;
                    message.ConferenceID=networkMngr.profile.ConferenceID;
                    message.CurrentPage=1;
                    message.senderProfile = networkMngr.profile;
                    message.sessionID = this.sessionID;
                    message.DocumentSharingSessionId = this.sessionID;
                    message.DownloadURL = Path.GetFileName(strPath);//this.strRemoteUrl;
                    message.DocumentType = this.m_DocumentType;
                    MessageObject Message2 = ((MessageObject)message);
                    if(networkMngr.StartDocumentSharing(ref Message2) == false)
                    {
                        if(OnStatusUpdateFunction !=null)
                            OnStatusUpdateFunction("Unable to Initialize Document Sharing. Please try again");
                        return false;
                    }
                    if(message.DocumentType==DocumentMessageType.typePDF)
                        this.strRemoteUrl+=("/"+Path.GetFileNameWithoutExtension(strPath));//this.strRemoteUrl;

                    message.DownloadURL=this.strRemoteUrl;/// Remote URL of the files

                    msg = message;
                    ((DocumentSharing)msg).TotalPages=((DocumentSharing)Message2).TotalPages;

                    //msg = Message2;
                    if(OnStatusUpdateFunction !=null)
                        OnStatusUpdateFunction("Starting Document Sharing.");

                    return true;
                }
            }
            catch(Exception exp)
            {
            WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage( "DocumentSharingEx.cs ==>DocumentShareStart(   line==>650",exp,null,false);
            }
            return false;
        }
Ejemplo n.º 2
0
        private void DocumentSharingThread()
        {
            //string strExt=".ppt";
            int no_of_RemoteFiles=8;
            string strPostRemoteUrl="";
            bool isRemoteUrlExist=false;
            string recordid="";
            MessageObject objMsg ;
            FileInfo theinfo;

            try
            {
                if(!this.IsLaunchFromMangeContent)
                {//in case false-----check manage content slideshow
                    //run when document is shared using menus.
                    //string Extension =strExt;//Path.GetExtension(DocumentFilePath);
                    string filename=Path.GetFileName(DocumentFilePath);
                    filenamed=Path.GetFileNameWithoutExtension(DocumentFilePath);
                    DocumentFilePath_temp=DocumentFilePath;
                    string Extension =Path.GetExtension(DocumentFilePath_temp);

                    theFile=new FileInfo(filename);

                    // 10 Mb Check
                    if((theFile.Length/1048576)>10)
                    {
                        MeetingAlerts alert=new MeetingAlerts();
                        alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"The size of this file is greater then 10Mb which may take time to Upload ",true,false);

                    }
                    //filenamed+=theFile.LastAccessTime.ToFileTime().ToString();

                    filenamed+=theFile.LastWriteTime.ToFileTime().ToString();
                    filenamed=filenamed.Replace('.','z');
                    filenamed=filenamed+Extension;
                    theFile.CopyTo(filenamed,true);
                    DocumentFilePath=Path.GetDirectoryName(DocumentFilePath)+@"\"+filenamed;
                    //DocumentFilePath=Path.GetFullPath(DocumentFilePath)+@"\"+filenamed;
                    Extension =Path.GetExtension(DocumentFilePath_temp);
                    //DocumentFilePath+=Extension
                    Extension = Extension.ToLower();

                    if(Extension == ".doc" ||Extension == ".docx")
                    {
                        documentType = DocumentMessageType.typeDocument;
                        strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                    }
                    else if(Extension == ".xls" ||Extension == ".xlsx")
                    {
                        documentType = DocumentMessageType.typeExcel;
                        if(no_of_RemoteFiles==1)
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        else
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                    }
                    else if(Extension == ".ppt" || Extension == ".pptx")
                    {
                        documentType = DocumentMessageType.typePresentation;
                        // German PPT
                        //strPostRemoteUrl="/Folie";
                        strPostRemoteUrl="/slide";
                    }
                    else if(Extension == ".pdf")
                    {
                        documentType = DocumentMessageType.typePDF;
                        strPostRemoteUrl="/index.htm";
                    }

                    theinfo=new FileInfo(this.DocumentFilePath);
                    recordid=Client.ClientUI.getInstance().findRecord(Path.GetFileName(this.DocumentFilePath),theinfo.LastWriteTime.ToShortDateString().ToString());
                    if(recordid!="-1")
                        isRemoteUrlExist=true;
                    else
                    {
                        strLocalPath="";
                        isRemoteUrlExist=false;
                    }

                    //         Zaeem
                    if(isRemoteUrlExist==false)
                    {
                        DocumentSharingEx docEx = new WebMeeting.Client.DocumentSharingEx(
                            documentType,this.sessionID,Info.getInstance().FtpIP,Info.getInstance().UserName,
                            Info.getInstance().Password,Info.getInstance().ConferenceID);

                        docEx.OnStatusUpdateFunction = new WebMeeting.Client.DocumentSharingEx.OnStatusUpdate(OnStatusUpdate);
                        //MessageObject objMsg ;

                        //			docEx.DocumentShareStart(DocumentFilePath,out objMsg);

                        if(!docEx.DocumentShareStart(DocumentFilePath,out objMsg))
                        {
                            //Handle the failure;
                            MeetingAlerts alert=new MeetingAlerts();
                            alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"Unable to upload document to webserver",true,false);
                            return;
                        }
                        //						if(WebMeeting.Client.ClientUI.getInstance().InsertNewRecord(filename,((DocumentSharing)objMsg).DownloadURL,this.DocumentFilePath,((DocumentSharing)objMsg).TotalPages,((DocumentSharing)objMsg).DocumentType.ToString(),this.sessionID))
                        //							MessageBox.Show("Record Inserted");
                        //						else
                        //							MessageBox.Show("Record Not Inserted");
                        //
                        if(Extension == ".doc" ||Extension == ".docx")
                        {
                            documentType = DocumentMessageType.typeDocument;
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        }
                        else if(Extension == ".xls" || Extension == ".xlsx")
                        {
                            documentType = DocumentMessageType.typeExcel;

                            if(((DocumentSharing)objMsg).TotalPages==1)
                                //if()
                                strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                            else
                                strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                        }
                        else if(Extension == ".ppt" || Extension == ".pptx")
                        {
                            documentType = DocumentMessageType.typePresentation;
                            // German PPT
                            //strPostRemoteUrl="/Folie";
                            strPostRemoteUrl="/slide";
                        }
                        else if(Extension == ".pdf")
                        {
                            documentType = DocumentMessageType.typePDF;
                            strPostRemoteUrl="/index.htm";
                        }

                        IntializationCompleted = true;
                        //((DocumentSharing)objMsg).TotalPages=no_of_RemoteFiles;

                        ((DocumentSharing)objMsg).DownloadURL+=strPostRemoteUrl;
                        //MessageBox.Show("==>((DocumentSharing)objMsg).DownloadURL"+((DocumentSharing)objMsg).DownloadURL);
                        this.pictureCount = ((DocumentSharing)objMsg).TotalPages;
                        //theinfo=new FileInfo(this.DocumentFilePath);
                        Client.ClientUI.getInstance().InsertNewRecord(Path.GetFileName(DocumentFilePath),((DocumentSharing)objMsg).DownloadURL, Application.StartupPath +"\\" + this.sessionID.ToString()  ,((DocumentSharing)objMsg).TotalPages,((DocumentSharing)objMsg).DocumentType.ToString(),this.sessionID,theinfo.LastWriteTime.ToShortDateString().ToString());
                        theinfo=null;
                    }
                        ////////////               BY Zaeem                     ///////
                    else
                    {
                        DocumentSharing msg=new DocumentSharing();
                        objMsg=msg;
                        DataRow drShareMessage;
                        drShareMessage=Client.ClientUI.getInstance().getRecord(Convert.ToInt32(recordid));
                        string Extsion =Path.GetExtension(drShareMessage["FileName"].ToString());
                        this.strLocalPath=drShareMessage["LocalPath"].ToString();
                        if(Extsion == ".doc" ||Extsion == ".docx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typeDocument;
                            //strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        }
                        else if(Extsion == ".xls" || Extsion == ".xlsx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typeExcel;
                            //							if(no_of_RemoteFiles==1)
                            //								strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                            //							else
                            //								strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                        }
                        else if(Extsion == ".ppt" || Extsion == ".pptx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typePresentation;
                            //	strPostRemoteUrl="/slide";
                        }
                        else if(Extsion == ".pdf")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typePDF;
                            //	strPostRemoteUrl="/index.htm";
                        }
                        this.documentType=((DocumentSharing)objMsg).DocumentType;
                        //drShareMessage["LocalPath"]
                        ((DocumentSharing)objMsg).SenderID= NetworkManager.getInstance().profile.ClientId;
                        ((DocumentSharing)objMsg).ConferenceID=NetworkManager.getInstance().profile.ConferenceID;
                        ((DocumentSharing)objMsg).senderProfile=NetworkManager.getInstance().profile;
                        //((DocumentSharing)objMsg).ConferenceID=Info.getInstance().ConferenceID;
                        ((DocumentSharing)objMsg).sessionID=Convert.ToInt32(drShareMessage["Session"].ToString());
                        ((DocumentSharing)objMsg).DocumentSharingSessionId=Convert.ToInt32(drShareMessage["Session"].ToString());
                        ((DocumentSharing)objMsg).CurrentPage=1;
                        //						((DocumentSharing)objMsg).MessageType=
                        ((DocumentSharing)objMsg).nScrollX=0;
                        ((DocumentSharing)objMsg).nScrollY=0;
                        this.sessionID=	Convert.ToInt32(drShareMessage["Session"].ToString());
                        IntializationCompleted = true;
                        //drShareMessage["Session"]
                        ((DocumentSharing)objMsg).TotalPages=Convert.ToInt32(drShareMessage["TotalPages"]);
                        ((DocumentSharing)objMsg).DownloadURL=drShareMessage["RemoteURL"].ToString();

                        this.pictureCount = ((DocumentSharing)objMsg).TotalPages;
                        drShareMessage=null;
                    }

                    ProcessMessage(objMsg); //TODO:: optimized way is to add this mssg to poll and let thread do it
                    //but this causses file sharing error while same machine testing

                    //MessagePool.Add(objMsg);
                    NetworkManager.getInstance().SendMessage(objMsg);
                }//end if
                else
                {//start else
                    //runs when document sharing starts from manage content slideshow page

                    string Extension = this.strExtension;//Path.GetExtension(DocumentFilePath);
                    Extension = Extension.ToLower();

                    if(Extension == ".doc" || Extension == ".docx")
                        documentType = DocumentMessageType.typeDocument;
                    else if(Extension == ".xls" || Extension == ".xlsx")
                        documentType = DocumentMessageType.typeExcel;
                    else if(Extension == ".ppt" || Extension == ".pptx")
                        documentType = DocumentMessageType.typePresentation;
                    else if(Extension == ".pdf")
                        documentType = DocumentMessageType.typePDF;

                    //					DocumentSharingEx docEx = new WebMeeting.Client.DocumentSharingEx(
                    //						documentType,this.sessionID,Info.getInstance().FtpIP,Info.getInstance().UserName,
                    //						Info.getInstance().Password,Info.getInstance().ConferenceID);

                    //					docEx.OnStatusUpdateFunction = new WebMeeting.Client.DocumentSharingEx.OnStatusUpdate(OnStatusUpdate);
                    //					MessageObject objMsg ;

                    //			docEx.DocumentShareStart(DocumentFilePath,out objMsg);

                    NetworkManager networkMngr = NetworkManager.getInstance();
                    WebMeeting.Common.DocumentSharing message = new WebMeeting.Common.DocumentSharing();
                    message.SenderID = networkMngr.profile.ClientId;
                    message.senderProfile = networkMngr.profile;
                    message.sessionID = this.sessionID;
                    message.DocumentSharingSessionId = this.sessionID;
                    message.DownloadURL = "Already Downloaded," + this.strRemoteUrl;
                    message.DocumentType = documentType;
                    message.CurrentPage=1;
                    message.TotalPages=this.no_of_pages;

                    /*if(!docEx.DocumentShareStart(DocumentFilePath,out objMsg))
                    {
                        //Handle the failure;
                        MeetingAlerts alert=new MeetingAlerts();
                        alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"Unable to upload document to webserver",true,false);
                        return;
                    }*/

                    IntializationCompleted = true;
                    //this.pictureCount = ((DocumentSharing)objMsg).TotalPages; //  by junaid for now
                    this.m_DocumentDownloaded=true;
                    this.ProcessMessageManageContent(message); //TODO:: optimized way is to add this mssg to poll and let thread do it
                    //but this causses file sharing error while same machine testing
                    this.m_DocumentMessage=	message;
                    message.DownloadURL="Already Downloaded," + message.DownloadURL;
                    //MessagePool.Add(objMsg);
                    NetworkManager.getInstance().SendMessage(message);
                }//end else

            }
            catch (WebException err)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("documentSharingControl.cs ==> DocumentSharingThread() line==> 1773",err,null,false);
                //MeetingAlerts alert=new MeetingAlerts();
                //alert.ShowMessage(Alerts.MeetingAlerts.AlertType.NonFatal,this.Name + " Class : DocumentSharingThread() function ," + ex.Source + " Source ," + ex.Message ,true,false);
            }

            finally
            {
                try
                {
                    theFile=new FileInfo(filenamed);
                    theFile.Delete();
                }
                catch(Exception exp){}
            }
        }