예제 #1
0
 public virtual void AddItem(ICalendarObject obj)
 {
     if (obj == null)
     {
         return;
     }
     else if (obj is Event)
     {
         Events.Add((Event)obj);
     }
     else if (obj is ToDo)
     {
         ToDos.Add((ToDo)obj);
     }
     else if (obj is JournalEntry)
     {
         JournalEntries.Add((JournalEntry)obj);
     }
     else if (obj is FreeBusy)
     {
         FreeBusy.Add((FreeBusy)obj);
     }
     else
     {
         throw new InvalidCastException();
     }
 }
예제 #2
0
        public void Save(Model.JournalModel journalModel)
        {
            JournalEntries journal = (JournalEntries)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oJournalEntries);

            try
            {
                if (journal.GetByKey(journalModel.TransId))
                {
                    SetFields(journal, journalModel);

                    journal.Update();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();
                }
                else
                {
                    SetFields(journal, journalModel);

                    journal.Add();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();
                }
            }
            finally
            {
                Marshal.ReleaseComObject(journal);
                GC.Collect();
            }
        }
예제 #3
0
        public int Add(oJournal obj)
        {
            JournalEntries jrnls = (JournalEntries)SboComObject.GetBusinessObject(BoObjectTypes.oJournalEntries);

            try
            {
                SboComObject.StartTransaction();

                int retCode = 0;

                jrnls.DueDate       = obj.DocDueDate;
                jrnls.TaxDate       = obj.TaxDate;
                jrnls.ReferenceDate = obj.DocDate;
                jrnls.Memo          = obj.JournalMemo;
                jrnls.ProjectCode   = obj.Project;

                if (obj.JournalLines.Count > 0)
                {
                    foreach (oJournalLine jrnlLine in obj.JournalLines)
                    {
                        jrnls.Lines.DueDate        = obj.DocDueDate;
                        jrnls.Lines.TaxDate        = obj.TaxDate;
                        jrnls.Lines.ReferenceDate1 = obj.DocDate;
                        jrnls.Lines.ShortName      = jrnlLine.GLCode;
                        jrnls.Lines.BPLID          = jrnlLine.Segment;
                        jrnls.Lines.Debit          = jrnlLine.Debit;
                        jrnls.Lines.Credit         = jrnlLine.Credit;
                        jrnls.Lines.Add();
                    }
                }

                retCode = jrnls.Add();
                if (retCode != 0)
                {
                    int    errCode    = 0;
                    string errMessage = "";
                    SboComObject.GetLastError(out errCode, out errMessage);
                    GlobalInstance.Instance.SBOErrorCode    = errCode;
                    GlobalInstance.Instance.SBOErrorMessage = errMessage;

                    SboComObject.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                else
                {
                    SboComObject.EndTransaction(BoWfTransOpt.wf_Commit);
                }

                return(retCode);
            }
            catch (Exception ex)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(jrnls);
                throw new Exception(GlobalInstance.Instance.SBOErrorMessage == null? ex.Message: GlobalInstance.Instance.SBOErrorMessage);
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(jrnls);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="je"></param>
        /// <returns></returns>
        public JournalEntries insertJE(JournalEntries je)
        {
            int    r      = 0;
            string msgSAP = "";
            int    jdtNum = 0;

            try
            {
                r      = je.Add();
                msgSAP = connection.Company.GetLastErrorDescription();
                string st = connection.Company.GetNewObjectKey();
                if (st.Equals("") || st.Length > 11)
                {
                    jdtNum = 0;
                    logger.log("Chave de Lancamento Manual nao retornada: " + st, Logger.LogType.WARNING, null, false);
                }
                else
                {
                    jdtNum = Convert.ToInt32(connection.Company.GetNewObjectKey());
                }
                //caso tenha inserido com sucesso carrega novamente
                //para ajustar o objeto
                if (r == 0)
                {
                    je.GetByKey(jdtNum);
                    logger.log("Lancamento Contabil manual inserido com sucesso " +
                               "(" + jdtNum + "). " + msgSAP, Logger.LogType.INFO);
                }
                else
                {
                    je = null;
                    logger.log("Erro ao inserir Lancamento Contabil Manual: " +
                               "\nRetorno SAP: " + r + " - " + msgSAP, Logger.LogType.ERROR, null, false);
                }
            }
            catch (Exception e)
            {
                je = null;
                logger.log("Erro ao inserir Lancamento Contabil Manual: " +
                           e.Message + " Retorno SAP: " + msgSAP, Logger.LogType.ERROR, e);
            }

            return(je);
        }
예제 #5
0
 public SampleDocument(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     try
     {
         var entries = new JournalEntries();
         int count   = info.GetInt32("EntryCount");
         for (int i = 0; i < count; ++i)
         {
             var entry = info.GetValue($"Entry{i}", typeof(JournalEntry)) as JournalEntry;
             entries.Add(entry);
         }
         _entries = entries;
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Unable to read Sample document", ex);
     }
 }
예제 #6
0
        public virtual void Deserialize(System.IO.TextReader rdr, Serializer serializer = null)
        {
            if (serializer == null)
            {
                serializer = new Serializer();
            }
            string name, value;
            var    parameters = new System.Collections.Specialized.NameValueCollection();

            while (rdr.Property(out name, out value, parameters) && !string.IsNullOrEmpty(name))
            {
                switch (name.ToUpper())
                {
                case "BEGIN":
                    switch (value)
                    {
                    case "VEVENT":
                        var e = serializer.GetService <Event>();
                        e.Calendar = this;
                        Events.Add(e);
                        e.Deserialize(rdr, serializer);
                        break;

                    case "VTIMEZONE":
                        var tz = serializer.GetService <TimeZone>();
                        tz.Calendar = this;
                        TimeZones.Add(tz);
                        tz.Deserialize(rdr, serializer);
                        break;

                    case "VTODO":
                        var td = serializer.GetService <ToDo>();
                        td.Calendar = this;
                        ToDos.Add(td);
                        td.Deserialize(rdr, serializer);
                        break;

                    case "VFREEBUSY":
                        var fb = serializer.GetService <FreeBusy>();
                        fb.Calendar = this;
                        FreeBusy.Add(fb);
                        fb.Deserialize(rdr, serializer);
                        break;

                    case "VJOURNAL":
                        var jn = serializer.GetService <JournalEntry>();
                        jn.Calendar = this;
                        JournalEntries.Add(jn);
                        jn.Deserialize(rdr, serializer);
                        break;
                    }
                    break;

                case "CALSCALE": Scale = value; break;

                case "VERSION": Version = value; break;

                case "PRODID": ProdID = value; break;

                case "END":
                    if (value == "VCALENDAR")
                    {
                        return;
                    }
                    break;

                default:
                    Properties.Add(Tuple.Create(name, value, parameters));
                    break;
                }
            }
        }