示例#1
0
        public List <Segment> getListSegment()
        {
            editorGrid.EndEdit();
            List <Segment> segments = new List <Segment>();

            foreach (DataGridViewRow row in editorGrid.Rows)
            {
                string target = null;
                string source = null;
                if (row.Cells["targetColumn"].Value != null)
                {
                    target = row.Cells["targetColumn"].Value.ToString();
                }
                if (row.Cells["sourceColumn"].Value != null)
                {
                    source = row.Cells["sourceColumn"].Value.ToString();
                }

                Segment segment = new Segment();
                tm      tm      = new tm();
                tm.Source = source;
                tm.Target = target;
                if (row.Cells["confirmColumn"].Value != null)
                {
                    segment.confirm = Convert.ToBoolean(row.Cells["confirmColumn"].Value);
                }
                segment.setTM(tm);
                segments.Add(segment);
            }

            return(segments);
        }
示例#2
0
        public static void GetLocalTimeExample()
        {
            int myTimer = 1;
            //have the structure assigned to get its size
            tm myTm = new tm();

            //get a pointer to the block of unmanaged memory
            IntPtr toBeMarshalled = Marshal.AllocHGlobal(Marshal.SizeOf(myTm));

            //Marshal.AllocCoTaskMem is from the COM task memory allocator
            //Marshal.AllocHGlobal is from the Win32 one
            try
            {
                //perform the unmanaged function call
                toBeMarshalled = localtime(ref myTimer);

                //marshal the pointer back to your structure as such
                myTm = (tm)Marshal.PtrToStructure(toBeMarshalled, typeof(tm));

                Console.WriteLine("myTm.tm_hour = '" + myTm.tm_hour + "'");
            }
            finally
            {
                // Marshal.FreeHGlobal(toBeMarshalled);
            }
        }
示例#3
0
 public void setTarget(List <Segment> segments)
 {
     for (int i = 0; i < segments.Count; i++)
     {
         tm temp = segments[i].getTM();
         listSegment[i].setTM(temp);
     }
 }
示例#4
0
        public void blockPushed()
        {
            Debug.Assert(!m_blockchain.empty());

            if (m_currency.upgradeHeight(new ushort(m_targetVersion)) != UNDEF_HEIGHT)
            {
                if (m_blockchain.size() <= m_currency.upgradeHeight(new ushort(m_targetVersion)) + 1)
                {
                    Debug.Assert(m_blockchain.back().bl.majorVersion <= m_targetVersion - 1);
                }
                else
                {
                    Debug.Assert(m_blockchain.back().bl.majorVersion >= m_targetVersion);
                }
            }
            else if (m_votingCompleteHeight != UNDEF_HEIGHT)
            {
                Debug.Assert(m_blockchain.size() > m_votingCompleteHeight);

                if (m_blockchain.size() <= upgradeHeight())
                {
                    Debug.Assert(m_blockchain.back().bl.majorVersion == m_targetVersion - 1);

                    if (m_blockchain.size() % (60 * 60 / m_currency.difficultyTarget()) == 0)
                    {
                        var      interval         = m_currency.difficultyTarget() * (upgradeHeight() - m_blockchain.size() + 2);
                        DateTime upgradeTimestamp = time(null) + (DateTime)interval;
                        tm       upgradeTime      = localtime(upgradeTimestamp);
                        string   upgradeTimeStr   = new string(new char[40]);
                        strftime(upgradeTimeStr, 40, "%H:%M:%S %Y.%m.%d", upgradeTime);
                        CryptoNote.CachedBlock cachedBlock = new CryptoNote.CachedBlock(m_blockchain.back().bl);

                        logger.functorMethod(Logging.Level.TRACE, Logging.BRIGHT_GREEN) << "###### UPGRADE is going to happen after block index " << upgradeHeight() << " at about " << upgradeTimeStr << " (in " << Common.timeIntervalToString(interval) << ")! Current last block index " << (m_blockchain.size() - 1) << ", hash " << cachedBlock.getBlockHash();
                    }
                }
                else if (m_blockchain.size() == upgradeHeight() + 1)
                {
                    Debug.Assert(m_blockchain.back().bl.majorVersion == m_targetVersion - 1);

                    logger.functorMethod(Logging.Level.TRACE, Logging.BRIGHT_GREEN) << "###### UPGRADE has happened! Starting from block index " << (upgradeHeight() + 1) << " blocks with major version below " << (int)m_targetVersion << " will be rejected!";
                }
                else
                {
                    Debug.Assert(m_blockchain.back().bl.majorVersion == m_targetVersion);
                }
            }
            else
            {
                uint lastBlockHeight = (uint)(m_blockchain.size() - 1);
                if (isVotingComplete(new uint(lastBlockHeight)))
                {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created:
//ORIGINAL LINE: m_votingCompleteHeight = lastBlockHeight;
                    m_votingCompleteHeight.CopyFrom(lastBlockHeight);
                    logger.functorMethod(Logging.Level.TRACE, Logging.BRIGHT_GREEN) << "###### UPGRADE voting complete at block index " << m_votingCompleteHeight << "! UPGRADE is going to happen after block index " << upgradeHeight() << "!";
                }
            }
        }
示例#5
0
 // Clean up
 private void invalidate()
 {
     _type    = ValueType.TypeInvalid;
     asStruct = null;
     asArray  = null;
     asString = null;
     asBinary = null;
     asBool   = false;
     asTime   = null;
 }
示例#6
0
文件: mtfutil.cs 项目: Luiz-Monad/mtf
 public static DateTime mktime(tm tbuf)
 {
     return(new DateTime(
                tbuf.tm_year,
                tbuf.tm_mon,
                tbuf.tm_mday,
                tbuf.tm_hour,
                tbuf.tm_min,
                tbuf.tm_sec));
 }
示例#7
0
文件: File.cs 项目: longsamaa/THESIS
 public void reWriteListSegment(List <Segment> listSegs)
 {
     //listSegments.Clear();
     for (int i = 0; i < listSegments.Count; i++)
     {
         tm tmp = new tm();
         tmp = listSegs[i].getTM();
         listSegments[i].setTM(tmp);
     }
 }
示例#8
0
        /*
        ** Compute the difference (in milliseconds) between localtime and UTC
        ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
        ** return this value and set *pRc to SQLITE_OK.
        **
        ** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
        ** is undefined in this case.
        */

        private static sqlite3_int64 localtimeOffset(
            DateTime p,                          /* Date at which to calculate offset */
            sqlite3_context pCtx,                /* Write error here if one occurs */
            out int pRc                          /* OUT: Error code. SQLITE_OK or ERROR */
            )
        {
            DateTime x;
            DateTime y = new DateTime();
            time_t   t;
            tm       sLocal = new tm();

            /* Initialize the contents of sLocal to avoid a compiler warning. */
            //memset(&sLocal, 0, sizeof(sLocal));

            x = p;
            computeYMD_HMS(x);
            if (x.Y < 1971 || x.Y >= 2038)
            {
                x.Y = 2000;
                x.M = 1;
                x.D = 1;
                x.h = 0;
                x.m = 0;
                x.s = 0.0;
            }
            else
            {
                int s = (int)(x.s + 0.5);
                x.s = s;
            }
            x.tz      = 0;
            x.validJD = 0;
            computeJD(x);
            t = (long)(x.iJD / 1000 - 210866760000L);            // (time_t)(x.iJD/1000 - 21086676*(i64)10000);
            if (osLocaltime(t, ref sLocal) != 0)
            {
                sqlite3_result_error(pCtx, "local time unavailable", -1);
                pRc = SQLITE_ERROR;
                return(0);
            }
            y.Y        = sLocal.tm_year;    // +1900;
            y.M        = sLocal.tm_mon;     // +1;
            y.D        = sLocal.tm_mday;
            y.h        = sLocal.tm_hour;
            y.m        = sLocal.tm_min;
            y.s        = sLocal.tm_sec;
            y.validYMD = 1;
            y.validHMS = 1;
            y.validJD  = 0;
            y.validTZ  = 0;
            computeJD(y);
            pRc = SQLITE_OK;
            return((int)(y.iJD - x.iJD));
        }
示例#9
0
        /*
        ** Return date: dd, mm, yyyy
        */
        private static void io_date()
        {
            time_t t = new time_t();
            tm     s = new tm();

            time(t);
            s = localtime(t);
            lua_pushnumber(s.tm_mday);
            lua_pushnumber(s.tm_mon + 1);
            lua_pushnumber(s.tm_year + 1900);
        }
示例#10
0
        /*
        ** Return time: hour, min, sec
        */
        private static void io_time()
        {
            time_t t = new time_t();
            tm     s = new tm();

            time(t);
            s = localtime(t);
            lua_pushnumber(s.tm_hour);
            lua_pushnumber(s.tm_min);
            lua_pushnumber(s.tm_sec);
        }
示例#11
0
 public void setListSegmentsFormFileSave()
 {
     if (listSegmentsFromSave.Count > 0)
     {
         foreach (Segment tmp in listSegmentsFromSave)
         {
             tm tm = tmp.getTM();
             setTargetToListSegment(tm);
         }
     }
 }
示例#12
0
文件: File.cs 项目: longsamaa/THESIS
        //public float checkFileIsChanged()
        //{
        //    int count = 0;
        //    if(listSegmentsFromSave.Count == 0)
        //    {
        //        progress = 0;
        //    }
        //    else
        //    {
        //        foreach(Segment segment in listSegmentsFromSave)
        //        {
        //            if(segment.getTMTarget() != null)
        //            {
        //                count++;
        //            }
        //        }
        //        progress = count/listSegmentsFromSave.Count
        //    }
        //}

        public void reWriteListSegmentSave(List <Segment> listSegs)
        {
            //listSegmentsFromSave.Clear();
            listSegmentsFromSave = listSegments;
            for (int i = 0; i < listSegs.Count; i++)
            {
                tm tmp = new tm();
                tmp = listSegs[i].getTM();
                listSegmentsFromSave[i].setTM(tmp);
                listSegmentsFromSave[i].confirm = listSegs[i].confirm;
            }
        }
    static void Main(string[] args)
    {
        var t     = new tm(tryMethod);
        var timer = new Timer();

        timer.Interval = 5000;

        timer.Start();

        timer.Elapsed += (sender, e) => timer_Elapsed(t);
        t.BeginInvoke(null, null);
    }
示例#14
0
        public static tm localtime(time_t t)
        {
            tm       result      = new tm();
            DateTime currentTime = DateTime.Now;

            result.tm_mday = currentTime.Day;
            result.tm_mon  = currentTime.Month - 1;            //+1
            result.tm_year = currentTime.Year - 1900;          //+1900
            result.tm_hour = currentTime.Hour;
            result.tm_min  = currentTime.Minute;
            result.tm_sec  = currentTime.Second;
            return(result);
        }
示例#15
0
        public List <Segment> readExcelFile(string path)
        {
            string         filename = Path.GetFileName(path);
            List <Segment> results  = new List <Segment>();

            try
            {
                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
                Workbook xlWorkbook = xlApp.Workbooks.Open(path, Type.Missing, true);
                int      countSheet = xlWorkbook.Sheets.Count;
                for (int i = 1; i <= countSheet; i++)
                {
                    _Worksheet xlWorksheet = (_Worksheet)xlWorkbook.Sheets[i];
                    Range      xlRange     = xlWorksheet.UsedRange;
                    foreach (Range c in xlRange.Rows.Cells)
                    {
                        if (c.Value2 != null)
                        {
                            string text;
                            if (c.Value2 is string)
                            {
                                text = c.Value2;
                            }
                            else
                            {
                                text = c.Value2.ToString();
                            }
                            tm tm = new tm();
                            tm.Source = text;
                            Segment tmp = new Segment();
                            tmp.row   = c.Row;
                            tmp.col   = c.Column;
                            tmp.sheet = i;
                            tmp.file  = filename;
                            tmp.setTM(tm);
                            results.Add(tmp);
                            //Console.WriteLine("row: " + c.Row + "Column " + c.Column + "value" + c.Value2 + "Sheet :" + i);
                        }
                    }
                }
                xlWorkbook.Close();
                xlApp.Quit();
                xlApp = null;
                //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkbook);
                //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlApp);
            }
            catch (Exception ex)
            {
            }
            return(results);
        }
示例#16
0
        public void addSegmentToTM()
        {
            //Console.WriteLine(editorGrid.CurrentRow.Index);
            editorGrid.EndEdit();
            int Index = editorGrid.CurrentRow.Index;

            if (editorGrid.Rows[Index].Cells["targetColumn"].Value != null && editorGrid.Rows[Index].Cells["sourceColumn"].Value != null)
            {
                string targetText = editorGrid.Rows[Index].Cells["targetColumn"].Value.ToString();
                string sourceText = editorGrid.Rows[Index].Cells["sourceColumn"].Value.ToString();
                DAOTM  daotm      = new DAOTM();
                if (mainForm.project != null)
                {
                    string tmname = mainForm.project.getTMName();
                    tm     tmp    = new tm()
                    {
                        Source = sourceText,
                        Target = targetText
                    };
                    Segment segment = new Segment();
                    segment.setTM(tmp);
                    if (tmp.Source != string.Empty && tmp.Target != string.Empty && tmname != string.Empty)
                    {
                        int result = daotm.addSegmentToTM(segment, tmname);
                        if (result != 1)
                        {
                            TextOfMessageBox a = new TextOfMessageBox();
                            MessageBox.Show(a.ADD_SEGMENT_FAILED, "Cảnh báo", MessageBoxButtons.YesNo);
                        }
                        else
                        {
                            if (result == 1)
                            {
                                lblStatus.Text = "Đã lưu thành công";
                                editorGrid.Rows[Index].Cells["confirmColumn"].Value = true;
                            }
                        }
                    }
                    else
                    {
                        TextOfMessageBox a = new TextOfMessageBox();
                        MessageBox.Show(a.EMPTY_TARGET, "Cảnh báo", MessageBoxButtons.YesNo);
                    }
                }
            }
            else
            {
                TextOfMessageBox a = new TextOfMessageBox();
                MessageBox.Show(a.EMPTY_TARGET, "Cảnh báo", MessageBoxButtons.YesNo);
            }
        }
示例#17
0
        public List <Segment> redPPTXFile(string path, char[] delimiters)
        {
            string         filename = Path.GetFileName(path);
            List <Segment> result   = new List <Segment>();

            try
            {
                Microsoft.Office.Interop.PowerPoint.Application   application         = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Application   pwpApp              = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = pwpApp.Presentations;
                Microsoft.Office.Interop.PowerPoint.Presentation  presentation        = multi_presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
                foreach (Slide slide in presentation.Slides)
                {
                    int indexShape = 1;
                    foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            var textFrame = shape.TextFrame;
                            if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                var           textRange = textFrame.TextRange;
                                string        text      = textRange.Text.ToString();
                                List <string> tmp       = splitTxtContentToSegment(text, delimiters);
                                foreach (string str in tmp)
                                {
                                    tm tm = new tm();
                                    tm.Source = str;
                                    int     indexSlide = slide.SlideIndex;
                                    Segment segment    = new Segment();
                                    segment.slide = indexSlide;
                                    segment.shape = indexShape;
                                    segment.file  = filename;
                                    segment.setTM(tm);
                                    result.Add(segment);
                                }
                            }
                        }
                        indexShape++;
                    }
                }

                presentation.Save();
                presentation.Close();
                pwpApp.Quit();
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
示例#18
0
 public void setTargetToListSegment(tm tm)
 {
     if (tm != null)
     {
         for (int i = 0; i < listSegments.Count; i++)
         {
             tm tmp = listSegments[i].getTM();
             if (tmp.Source == tm.Source)
             {
                 listSegments[i].setTMTargetLang(tm.Target);
             }
         }
     }
 }
示例#19
0
        static int OsLocaltime(time_t t, tm tm_)
        {
            int rc;
            MutexEx mutex = MutexEx.Alloc(MutexEx.MUTEX.STATIC_MASTER);
            MutexEx.Enter(mutex);
            tm x = localtime(t);
#if !OMIT_BUILTIN_TEST
            if (_localtimeFault) x = null;
#endif
            if (x != null) tm_ = x;
            MutexEx.Leave(mutex);
            rc = (x == null ? 1 : 0);
            return rc;
        }
示例#20
0
        public List <Segment> splitTxtContentToSegment(string content, char[] delimiters, int page)
        {
            var parts = new List <Segment>();

            if (!string.IsNullOrEmpty(content))
            {
                int iFirst = 0;
                do
                {
                    int iLast = content.IndexOfAny(delimiters, iFirst);
                    if (content[iLast] != '\n' && content[iLast + 1] != '\n')
                    {
                        if (iLast >= 0)
                        {
                            if (iLast > iFirst)
                            {
                                if (iLast != iFirst)
                                {
                                    string str1 = content.Substring(iFirst, iLast - iFirst + 1).Trim();
                                    if (str1 != "")
                                    {
                                        tm tm1 = new tm();
                                        tm1.Source = str1;
                                        Segment tmp1 = new Segment();
                                        tmp1.setTM(tm1);
                                        tmp1.setPage(page);
                                        parts.Add(tmp1);
                                    }
                                }
                            }
                            iFirst = iLast + 1;
                            continue;
                        }
                    }
                    string str = content.Substring(iFirst, content.Length - iFirst).Trim();
                    if (str != "")
                    {
                        tm tm = new tm();
                        tm.Source = str;
                        Segment tmp = new Segment();
                        tmp.setTM(tm);
                        tmp.setPage(page);
                        parts.Add(tmp);
                    }
                    break;
                } while (iFirst < content.Length);
            }

            return(parts);
        }
示例#21
0
        static long LocaltimeOffset(DateTime p, FuncContext fctx, out RC rc)
        {
            // Initialize the contents of sLocal to avoid a compiler warning.
            tm sLocal = new tm();

            DateTime x = p;
            ComputeYMD_HMS(x);
            if (x.Y < 1971 || x.Y >= 2038)
            {
                x.Y = 2000;
                x.M = 1;
                x.D = 1;
                x.h = 0;
                x.m = 0;
                x.s = 0.0;
            }
            else
            {
                int s = (int)(x.s + 0.5);
                x.s = s;
            }
            x.tz = 0;
            x.ValidJD = false;
            ComputeJD(x);
            time_t t = (long)(x.JD / 1000 - 210866760000L);
            if (OsLocaltime(t, sLocal) != 0)
            {
                Vdbe.Result_Error(fctx, "local time unavailable", -1);
                rc = RC.ERROR;
                return 0;
            }
            DateTime y = new DateTime();
            y.Y = sLocal.tm_year; // +1900;
            y.M = sLocal.tm_mon; // +1;
            y.D = sLocal.tm_mday;
            y.h = sLocal.tm_hour;
            y.m = sLocal.tm_min;
            y.s = sLocal.tm_sec;
            y.ValidYMD = true;
            y.ValidHMS = true;
            y.ValidJD = false;
            y.ValidTZ = false;
            ComputeJD(y);
            rc = RC.OK;
            return (int)(y.JD - x.JD);
        }
示例#22
0
        public static tm localtime(time_t baseTime)
        {
            System.DateTime RefTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
            RefTime = RefTime.AddSeconds(Convert.ToDouble(baseTime)).ToLocalTime();
            tm tm = new tm();

            tm.tm_sec   = RefTime.Second;
            tm.tm_min   = RefTime.Minute;
            tm.tm_hour  = RefTime.Hour;
            tm.tm_mday  = RefTime.Day;
            tm.tm_mon   = RefTime.Month;
            tm.tm_year  = RefTime.Year;
            tm.tm_wday  = (int)RefTime.DayOfWeek;
            tm.tm_yday  = RefTime.DayOfYear;
            tm.tm_isdst = RefTime.IsDaylightSavingTime() ? 1 : 0;
            return(tm);
        }
示例#23
0
        public List <Segment> readSegmentFromFileSave(string path)
        {
            List <Segment> listSegs = new List <Segment>();
            XmlTextReader  xtr      = new XmlTextReader(path);
            string         sourceText;
            string         TargetText;
            string         confirmText;
            int            index = 0;

            try
            {
                if (xtr.Read() != null)
                {
                    while (xtr.Read())
                    {
                        if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "Source_Text")
                        {
                            sourceText = xtr.ReadElementString();
                            tm tm = new tm();
                            tm.Source = sourceText;
                            Segment tmp = new Segment();
                            tmp.setTM(tm);
                            listSegs.Add(tmp);
                        }
                        if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "Target_Text")
                        {
                            TargetText = xtr.ReadElementString();
                            listSegs[index].setTMTargetLang(TargetText);
                            //index++;
                        }
                        if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "Value")
                        {
                            confirmText             = xtr.ReadElementString();
                            listSegs[index].confirm = bool.Parse(confirmText);
                            index++;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            xtr.Close();
            return(listSegs);
        }
示例#24
0
        public override void createFileTranslateDocument()
        {
            txtProc txtProc = new txtProc();

            if (this.content.Length > 0)
            {
                foreach (Segment a in listSegments)
                {
                    tm tmp = a.getTM();
                    if (tmp.Target != null)
                    {
                        if (tmp.Target.Trim() != "")
                        {
                            this.content = txtProc.ReplaceFirst(this.content, tmp.Source, tmp.Target);
                        }
                    }
                }
            }
        }
示例#25
0
        public static DateTime OleDateDecode(DATE dtSrc)
        {
            tm tmDest = new tm();

            if (!OleDateDecode(dtSrc, ref tmDest, false))
            {
                return(new DateTime(1899, 12, 30));//0
            }
            else if (dtSrc > 0.000001)
            {
                DateTime dtDest = new DateTime(tmDest.tm_year, tmDest.tm_mon, tmDest.tm_mday, tmDest.tm_hour, tmDest.tm_min, tmDest.tm_sec, tmDest.tm_msec);
                return(dtDest);
            }
            else
            {
                DateTime dtDest = DateTime.Now;
                return(dtDest);
            }
        }
示例#26
0
        private DateTime?FetchDate(System.Int16 index)
        {
            tm TM = new tm();

            System.Int32 err_no = Wrapper10.SE_stream_get_date(_stream.SeStream, index, ref TM);

            if (err_no == -1004)
            {
                return(null);
            }
            if (err_no != 0)
            {
                return(new DateTime(1, 1, 1));
            }

            return(new DateTime(
                       TM.tm_year + 1900,
                       TM.tm_mon + 1,
                       TM.tm_mday));
        }
示例#27
0
文件: editor.cs 项目: longsamaa/CAT
        private void editorGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int Index = e.RowIndex;

            if (editorGrid.Rows[Index].Cells["targetColumn"].Value != null)
            {
                string TargetText = editorGrid.Rows[Index].Cells["targetColumn"].Value.ToString();
                string SourceText = editorGrid.Rows[Index].Cells["sourceColumn"].Value.ToString();
                if (mainForm.project != null)
                {
                    mainForm.project.setTargetLangToCurrentFileListSegment(Index, TargetText);
                    tm tm = new tm();
                    tm.Source = SourceText;
                    tm.Target = TargetText;
                    Segment tmp = new Segment();
                    tmp.setTM(tm);
                    mainForm.project.addSegmentToListSaveSegment(tmp);
                }
            }
        }
示例#28
0
        public string replaceContent()
        {
            txtProc txtProc        = new txtProc();
            string  contentReplace = this.content;

            if (this.content.Length > 0)
            {
                foreach (Segment a in listSegments)
                {
                    tm tmp = a.getTM();
                    if (tmp.Target != null)
                    {
                        if (tmp.Target.Trim() != "")
                        {
                            contentReplace = txtProc.ReplaceFirst(contentReplace, tmp.Source, tmp.Target);
                        }
                    }
                }
            }
            return(contentReplace);
        }
示例#29
0
        // Works for strings, binary data, arrays, and structs.

        public void Copy(XmlRpcValue other)
        {
            switch (other._type)
            {
            case ValueType.TypeBoolean:
                asBool = other.asBool;
                break;

            case ValueType.TypeInt:
                asInt = other.asInt;
                break;

            case ValueType.TypeDouble:
                asDouble = other.asDouble;
                break;

            case ValueType.TypeDateTime:
                asTime = other.asTime;
                break;

            case ValueType.TypeString:
                asString = other.asString;
                break;

            case ValueType.TypeBase64:
                asBinary = other.asBinary;
                break;

            case ValueType.TypeArray:
                asArray = other.asArray;
                break;

            // The map<>::operator== requires the definition of value< for kcc
            case ValueType.TypeStruct:     //return *_value.asStruct == *other._value.asStruct;
                asStruct = other.asStruct;
                break;
            }
            _type = other._type;
        }
示例#30
0
        /*
        ** On recent Windows platforms, the localtime_s() function is available
        ** as part of the "Secure CRT". It is essentially equivalent to
        ** localtime_r() available under most POSIX platforms, except that the
        ** order of the parameters is reversed.
        **
        ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
        **
        ** If the user has not indicated to use localtime_r() or localtime_s()
        ** already, check for an MSVC build environment that provides
        ** localtime_s().
        */
        //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
        //     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
        //#define HAVE_LOCALTIME_S 1
        //#endif

#if !SQLITE_OMIT_LOCALTIME
        /*
        ** The following routine implements the rough equivalent of localtime_r()
        ** using whatever operating-system specific localtime facility that
        ** is available.  This routine returns 0 on success and
        ** non-zero on any kind of error.
        **
        ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
        ** routine will always fail.
        */

        private static int osLocaltime(time_t t, ref tm pTm)
        {
            int rc;

#if (!(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) && (!(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
            tm            pX;
            sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
            sqlite3_mutex_enter(mutex);
            pX = localtime(t);
#if !SQLITE_OMIT_BUILTIN_TEST
            if (sqlite3GlobalConfig.bLocaltimeFault)
            {
                pX = null;
            }
#endif
            if (pX != null)
            {
                pTm = pX;
            }
            sqlite3_mutex_leave(mutex);
            rc = pX == null ? 1 : 0;
#else
#if !SQLITE_OMIT_BUILTIN_TEST
            if (sqlite3GlobalConfig.bLocaltimeFault)
            {
                return(1);
            }
#endif
#if (HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R
            rc = localtime_r(t, pTm) == 0;
#else
            rc = localtime_s(pTm, t);
#endif //* HAVE_LOCALTIME_R */
#endif //* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */
            return(rc);
        }
示例#31
0
        public static void GetLocalTimeExample()
        {
            int myTimer = 1;
            //have the structure assigned to get its size
            tm myTm = new tm();

            //get a pointer to the block of unmanaged memory
            IntPtr toBeMarshalled = Marshal.AllocHGlobal(Marshal.SizeOf(myTm));

            //Marshal.AllocCoTaskMem is from the COM task memory allocator
            //Marshal.AllocHGlobal is from the Win32 one
            try
            {
                //perform the unmanaged function call
                toBeMarshalled = localtime(ref myTimer);

                //marshal the pointer back to your structure as such
                myTm = (tm) Marshal.PtrToStructure(toBeMarshalled, typeof (tm));

                Console.WriteLine("myTm.tm_hour = '" + myTm.tm_hour + "'");
            }
            finally
            {
                // Marshal.FreeHGlobal(toBeMarshalled);
            }
        }
示例#32
0
 public OsdbMapper(tm.TransactionManager tm)
 {
     this._tm = tm;
     this._config = this._tm.transactionConfig();
     this._defaults = new util.SystemDefaults();
 }
示例#33
0
    /*
** Compute the difference (in milliseconds) between localtime and UTC
** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
** return this value and set *pRc to SQLITE_OK. 
**
** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
** is undefined in this case.
*/
    static sqlite3_int64 localtimeOffset(
      DateTime p,                    /* Date at which to calculate offset */
      sqlite3_context pCtx,          /* Write error here if one occurs */
      out int pRc                    /* OUT: Error code. SQLITE_OK or ERROR */
    )
    {
      DateTime x;
      DateTime y = new DateTime();
      time_t t;
      tm sLocal = new tm();

      /* Initialize the contents of sLocal to avoid a compiler warning. */
      //memset(&sLocal, 0, sizeof(sLocal));

      x = p;
      computeYMD_HMS( x );
      if ( x.Y < 1971 || x.Y >= 2038 )
      {
        x.Y = 2000;
        x.M = 1;
        x.D = 1;
        x.h = 0;
        x.m = 0;
        x.s = 0.0;
      }
      else
      {
        int s = (int)( x.s + 0.5 );
        x.s = s;
      }
      x.tz = 0;
      x.validJD = 0;
      computeJD( x );
      t = (long)( x.iJD / 1000 - 210866760000L );// (time_t)(x.iJD/1000 - 21086676*(i64)10000);
      if ( osLocaltime( t, sLocal ) != 0 )
      {
        sqlite3_result_error( pCtx, "local time unavailable", -1 );
        pRc = SQLITE_ERROR;
        return 0;
      }
      y.Y = sLocal.tm_year;// +1900;
      y.M = sLocal.tm_mon;// +1;
      y.D = sLocal.tm_mday;
      y.h = sLocal.tm_hour;
      y.m = sLocal.tm_min;
      y.s = sLocal.tm_sec;
      y.validYMD = 1;
      y.validHMS = 1;
      y.validJD = 0;
      y.validTZ = 0;
      computeJD( y );
      pRc = SQLITE_OK;
      return (int)( y.iJD - x.iJD );
    }
示例#34
0
    /*
    ** On recent Windows platforms, the localtime_s() function is available
    ** as part of the "Secure CRT". It is essentially equivalent to 
    ** localtime_r() available under most POSIX platforms, except that the 
    ** order of the parameters is reversed.
    **
    ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
    **
    ** If the user has not indicated to use localtime_r() or localtime_s()
    ** already, check for an MSVC build environment that provides 
    ** localtime_s().
    */
    //#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
    //     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
    //#define HAVE_LOCALTIME_S 1
    //#endif

#if !SQLITE_OMIT_LOCALTIME
    /*
    ** The following routine implements the rough equivalent of localtime_r()
    ** using whatever operating-system specific localtime facility that
    ** is available.  This routine returns 0 on success and
    ** non-zero on any kind of error.
    **
    ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
    ** routine will always fail.
    */
    static int osLocaltime( time_t t, tm pTm )
    {
      int rc;
#if (!(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) && (!(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
      tm pX;
      sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER );
      sqlite3_mutex_enter( mutex );
      pX = localtime( t );
#if !SQLITE_OMIT_BUILTIN_TEST
      if ( sqlite3GlobalConfig.bLocaltimeFault )
        pX = null;
#endif
      if ( pX != null )
        pTm = pX;
      sqlite3_mutex_leave( mutex );
      rc = pX == null ? 1 : 0;
#else
#if !SQLITE_OMIT_BUILTIN_TEST
  if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
#endif
#if (HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R
  rc = localtime_r(t, pTm)==0;
#else
  rc = localtime_s(pTm, t);
#endif //* HAVE_LOCALTIME_R */
#endif //* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */
      return rc;
    }