Пример #1
0
        public CSDocument OpenDocument(string label)
        {
            CSDocument result = new CSDocument();

            //result.Load(label);
            try
            {
                Document apiDoc = CodeSoftApi.Documents.Open(label, true);
                result.Load(apiDoc, label);
                apiDoc.Close(false);
                apiDoc.Dispose();
            }
            catch (Exception err)
            {
                string sessionId = string.Empty;
                if (SessionManager.GetSession() != null)
                {
                    sessionId = SessionManager.GetSession().ID;
                }
                APIEvent(this, new CSNetAppEventArgs()
                {
                    DocFail = true, SessionId = sessionId
                });
                _NetApp = null;
                log4net.LogManager.GetLogger("ERROR").Error(new Exception("Failed to open Document for label " + label + " : " + err.Message));
                /*Can one really error handle a  COM++ ?*/
            }

            return(result);
        }
Пример #2
0
 public void Dispose()
 {
     if (_CurrentDocument != null)
     {
         try
         {
             //_CurrentDocument.Close(false);
             _CurrentDocument = null;
             //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Document Dispose. Session ID:" + ID));
         }
         catch (Exception err)
         {
             log4net.LogManager.GetLogger("DEBUG").Error(err);
         }
     }
     if (_CurrentLabel != null)
     {
         _CurrentLabel.CSVariables.Clear();
         _CurrentLabel = null;
     }
 }
Пример #3
0
 /// <summary>
 /// Sets an immutable reference to the current CSLabel
 /// </summary>
 /// <param name="label"></param>
 public void SetLabel(CSLabel label)
 {
     if (label == null)
     {
         Dispose();
     }
     else
     {
         //prevent mutation
         CSLabel obj = CSLabelManager.GetLabel(label.Name, label.Path);
         obj.AddVariables(label.CSVariables);
         this._CurrentLabel = obj;
         //if (this._CurrentDocument != null)
         //this._CurrentDocument.Close(false);
         CSDocument Doc = SessionManager.Documents.Where(p => p.LabelPath == label.Path).FirstOrDefault();
         this._CurrentDocument = Doc;
         if (Doc == null)
         {
             Doc = CSNetApp.Instance.OpenDocument(obj.Path);
             this._CurrentDocument = Doc;
             SessionManager.Documents.Add(Doc);
         }
     }
 }
Пример #4
0
 public void CloseDocument()
 {
     //_CurrentDocument.Close(false);
     this._CurrentDocument = null;
 }