Exemplo n.º 1
0
        private void materialButton_addnew_Click(object sender, EventArgs e)
        {
            if (betterTextBox_counterno.Text.Trim() == "")
            {
                INFO.ShowAlert(Text, "Please Enter Counter Name", 3000);
                betterTextBox_counterno.Focus();
                return;
            }
            //try
            //{

            this.Counter.name            = betterTextBox_counterno.Text;
            this.Counter.updated_at      = DateTime.Now;
            this.Counter.created_at      = DateTime.Now;
            db.Entry(this.Counter).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            edit?.Invoke(Counter);
            this.Close();
            //}
            ////catch (Exception)
            //{

            //    CustomControls.Alert.show("Error", "data is not edited", 1500);
            //}
        }
Exemplo n.º 2
0
        public CSTM(byte[] Data)
        {
            EndianBinaryReader er = new EndianBinaryReader(new MemoryStream(Data), Endianness.LittleEndian);

            try
            {
                Header = new CSTMHeader(er);
                er.BaseStream.Position = Header.Sections[0].Offset;
                Info = new INFO(er);
                if (Header.NrSections > 2 && Header.Sections[1].Id == 0x4001)
                {
                    er.BaseStream.Position = Header.Sections[1].Offset;
                    Seek = new SEEK(er);
                    er.BaseStream.Position = Header.Sections[2].Offset;
                    this.Data = new DATA(er);
                }
                else
                {
                    er.BaseStream.Position = Header.Sections[1].Offset;
                    this.Data = new DATA(er);
                }
            }
            finally
            {
                er.Close();
            }
        }
Exemplo n.º 3
0
        public SiapTable()
        {
            SDSSgetImage  = ConfigurationSettings.AppSettings["UrlSdssGetJpeg"];
            latestRelease = ConfigurationSettings.AppSettings["LatestRelease"];
            datarelease   = getDataRelease();

            if (null == SDSSgetImage)
            {
                throw new Exception(" Please set UrlSdssGetJpeg in web.config");
            }
            SDSSgetImage = SDSSgetImage.Replace("VERSION", datarelease);


            //this.version = net.ivoa.VOTable.VOTABLEVersion.Item11;
            this.RESOURCE         = new RESOURCE[1];
            this.RESOURCE[0]      = new RESOURCE();
            this.RESOURCE[0].type = RESOURCEType.results;

            INFO info = new INFO();

            info.name  = "QUERY_STATUS";
            info.value = "OK";

            this.INFO    = new INFO[1];
            this.INFO[0] = info;

            this.RESOURCE[0].TABLE    = new TABLE[1];
            this.RESOURCE[0].TABLE[0] = new TABLE();
        }
Exemplo n.º 4
0
        /// <summary> It reads the morpheme dictionary file, and initializes the trie structure.</summary>
        /// <param name="dictionaryFileName">- the file path of the morpheme dictionary
        /// </param>
        /// <param name="tagSet">- the morpheme tag set
        /// </param>
        /// <throws>  IOException </throws>
        public virtual void  read_dic(System.String dictionaryFileName, TagSet tagSet)
        {
            System.String str = "";

            System.IO.StreamReader in_Renamed = new System.IO.StreamReader(
                new System.IO.FileStream(dictionaryFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read),
                System.Text.Encoding.UTF8);
            INFO[] info_list = new INFO[255];
            for (int i = 0; i < 255; i++)
            {
                info_list[i] = new INFO(this);
            }

            while ((str = in_Renamed.ReadLine()) != null)
            {
                str.Trim();
                if (str.Equals(""))
                {
                    continue;
                }

                StringTokenizer tok   = new StringTokenizer(str, "\t ");
                System.String   word  = tok.NextToken;
                int             isize = 0;

                while (tok.HasMoreTokens)
                {
                    System.String   data = tok.NextToken;
                    StringTokenizer tok2 = new StringTokenizer(data, ".");
                    System.String   curt = tok2.NextToken;
                    int             x    = tagSet.getTagID(curt);
                    if (x == -1)
                    {
                        System.Console.Error.WriteLine("read_dic:tag error");
                        continue;
                    }

                    if (tok2.HasMoreTokens)
                    {
                        info_list[isize].phoneme = (short)tagSet.getIrregularID(tok2.NextToken);
                    }
                    else
                    {
                        info_list[isize].phoneme = TagSet.PHONEME_TYPE_ALL;
                    }

                    info_list[isize].tag = x;
                    isize++;
                }
                info_list[isize].tag     = 0;
                info_list[isize].phoneme = 0;

                char[] word3 = Code.toTripleArray(word);
                for (int i = 0; i < isize; i++)
                {
                    store(word3, info_list[i]);
                }
            }
        }
Exemplo n.º 5
0
 public static extern ReturnCodes CredUIPromptForCredentials(
     ref INFO creditUR,
     string targetName,
     IntPtr reserved1,
     int iError,
     StringBuilder userName,
     int maxUserName,
     StringBuilder password,
     int maxPassword,
     ref int iSave,
     CredFlags credFlags
     );
Exemplo n.º 6
0
            public void Read(FileReader reader, INFO INFO)
            {
                string Signature = reader.ReadString(4, Encoding.ASCII);

                if (Signature != "FILE")
                {
                    throw new Exception($"Invalid signature {Signature}! Expected FILE.");
                }

                SectionSize = reader.ReadUInt32();
                byte[] padding = reader.ReadBytes(0x18);
            }
Exemplo n.º 7
0
        public void reportError(string error)
        {
            this.version = net.ivoa.VOTable.VOTABLEVersion.Item11;
            INFO info = new INFO();

            info.name    = "QUERY_STATUS";
            info.value   = "ERROR";
            info.Text    = new string[1];
            info.Text[0] = error;

            this.INFO    = new INFO[3];
            this.INFO[0] = info;
            addUrlInfo(1);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 应用程序配置管理
 /// </summary>
 /// <param name="dt">DC_RA_CONFIG表</param>
 public ConfigurationManager(DataTable dt)
 {
     if (dt == null)
     {
         return;
     }
     foreach (DataRow dr in dt.Rows)
     {
         INFO i = new INFO();
         i.Namespace = dr["C_NAMESPACE"].ToString().Trim().ToUpper();
         i.Keyname   = dr["C_KEY"].ToString().Trim().ToUpper();
         i.Value     = dr["C_VALUE"].ToString();
         Infos.Add(i);
     }
 }
Exemplo n.º 9
0
        public BaslerCamera(string ip)
        {
            foreach (ICameraInfo INFO in CameraFinder.Enumerate())
            {
                if (INFO.GetValueOrDefault("IpAddress", "0") == ip)
                {
                    camera = new Camera(INFO);
                    break;
                }
            }
            if (camera == null)
            {
                camera = new Camera();
            }

            grabbing = false;
        }
Exemplo n.º 10
0
            public void Read(FileReader reader)
            {
                string Signature = reader.ReadString(4, Encoding.ASCII);

                if (Signature != "FSAR")
                {
                    throw new Exception($"Invalid signature {Signature}! Expected FSAR.");
                }
                BOM        = reader.ReadUInt16();
                HeaderSize = reader.ReadUInt16();
                Version    = reader.ReadUInt32();
                uint FileSize = reader.ReadUInt32();

                SectionCount = reader.ReadUInt16();
                ushort padding = reader.ReadUInt16();

                for (int i = 0; i < SectionCount; i++)
                {
                    ushort Identifier = reader.ReadUInt16();
                    ushort padding2   = reader.ReadUInt16();
                    uint   Offset     = reader.ReadUInt32();
                    uint   Size       = reader.ReadUInt32();

                    if (Identifier == 8192)
                    {
                        reader.Seek(Offset, SeekOrigin.Begin);
                        STRG = new STRG();
                        STRG.Read(reader);
                    }
                    if (Identifier == 8193)
                    {
                        reader.Seek(Offset, SeekOrigin.Begin);
                        INFO = new INFO();
                        INFO.Read(reader);
                    }
                    if (Identifier == 8194)
                    {
                        reader.Seek(Offset, SeekOrigin.Begin);
                        FILE = new FILE();
                        FILE.Read(reader, INFO);
                    }
                }

                reader.Close();
                reader.Dispose();
            }
Exemplo n.º 11
0
        /// <summary>
        /// Initialise the Yubikey and get its status
        /// </summary>
        /// <param name="waitms"></param>
        public void Init()
        {
            lock (_initLock)
            {
                if (Info.Status.VersionMajor != 0)
                {
                    return;
                }

                // load library and load info
                LoadLibrary();
                INFO            info = new INFO();
                GetInfoDelegate f    = GetFunction <GetInfoDelegate>("GetInfo");
                int             ret  = f(out info);
                if (ret > 1)
                {
                    info.Error = string.Format("Error {0}", ret);
                }
                Info = info;
            }
        }
Exemplo n.º 12
0
        public string EditProductInfo(InfoModel info)
        {
            if (Session["login"] is null)
            {
                return("");
            }

            if (String.IsNullOrEmpty(info.InfoName) || String.IsNullOrEmpty(info.InfoCategory))
            {
                return("Vui lòng nhập đầy đủ thông tin");
            }

            using (THUONGMAIDIENTUEntities db = new THUONGMAIDIENTUEntities())
            {
                INFO i = new INFO();
                if (info.IdInfo > 0)
                {
                    i = db.INFOes.Where(x => x.IdInfo == info.IdInfo).FirstOrDefault();
                }
                if (i is null)
                {
                    return("Dữ liệu bất thường vui lòng thử lại sau");
                }
                i.InfoName     = info.InfoName;
                i.InfoCategory = info.InfoCategory.ToUpper();
                if (info.IdInfo == 0)
                {
                    db.INFOes.Add(i);
                }
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            return("ok");
        }
Exemplo n.º 13
0
        public void Parse_Sections()
        {
            var sut      = new INFO(INFO.AllSections);
            var sections = allSections.Accept(sut.ResponseStructure);

            sections
            .Select(section => section.Name)
            .Should()
            .Equal(
                "Server",
                "Clients",
                "Memory",
                "Persistence",
                "Stats",
                "Replication",
                "CPU",
                "Modules",
                "Commandstats",
                "Cluster",
                "Keyspace"
                );
        }
Exemplo n.º 14
0
 private void materialButton_setDefault_Click(object sender, EventArgs e)
 {
     if (loaded)
     {
         if (db.systemsettings.Count() > 0)
         {
             var setting = db.systemsettings.First();
             setting.fiscalyear_id   = this.Fiscalyear.id;
             db.Entry(setting).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         else
         {
             var setting = new Model.systemsetting()
             {
                 fiscalyear_id = this.Fiscalyear.id
             };
             db.systemsettings.Add(setting);
             db.SaveChanges();
         }
         INFO.ShowAlert("", this.Fiscalyear.name + " set as current Fiscal Year", 3000);
     }
 }
Exemplo n.º 15
0
        public CSAR(byte[] Data)
        {
            EndianBinaryReaderEx er = new EndianBinaryReaderEx(new MemoryStream(Data), Endianness.LittleEndian);

            try
            {
                Header = new CSARHeader(er);
                foreach (var v in Header.Sections)
                {
                    er.BaseStream.Position = v.Offset;
                    switch (v.Id)
                    {
                    case 0x2000: Strings = new STRG(er); break;

                    case 0x2001: Infos = new INFO(er); break;
                    }
                }
            }
            finally
            {
                er.Close();
            }
        }
Exemplo n.º 16
0
        //FILEBlock

        public SDAT(byte[] bytes)
        {
            using (var er = new EndianBinaryReader(new MemoryStream(bytes)))
            {
                FileHeader = er.ReadObject <FileHeader>();
                SYMBOffset = er.ReadInt32();
                SYMBLength = er.ReadInt32();
                INFOOffset = er.ReadInt32();
                INFOLength = er.ReadInt32();
                FATOffset  = er.ReadInt32();
                FATLength  = er.ReadInt32();
                FILEOffset = er.ReadInt32();
                FILELength = er.ReadInt32();
                Padding    = er.ReadBytes(16);

                if (SYMBOffset != 0 && SYMBLength != 0)
                {
                    SYMBBlock = er.ReadObject <SYMB>(SYMBOffset);
                }
                INFOBlock = er.ReadObject <INFO>(INFOOffset);
                FATBlock  = er.ReadObject <FAT>(FATOffset);
            }
        }
Exemplo n.º 17
0
        public SiapTable()
        {
            ///******
            ///This part is added to get any data release working with thsi DR1 to DRxx
            ///******
            //datarelease = HttpContext.Current.Request.RequestContext.RouteData.Values["anything"] as string;
            datarelease = ConfigurationManager.AppSettings["DataRelease"];
            //this.datarelease = datarelease;
            this.casjobstaskname = "SDSSFields For SIAP";

            SDSSgetImage = SDSSgetImage.Replace("*DataRelease*", datarelease);
            string[] temp = HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Split(new string[] { "siap" }, StringSplitOptions.None);
            UrlSdssFields = temp[0] + "SDSSFields";
            //****

            ////old code
            //if (null != ppd)
            //{
            //    this.pixPerDeg = Convert.ToInt32(ppd);
            //}

            this.version          = net.ivoa.VOTable.VOTABLEVersion.Item11;
            this.RESOURCE         = new RESOURCE[1];
            this.RESOURCE[0]      = new RESOURCE();
            this.RESOURCE[0].type = RESOURCEType.results;

            INFO info = new INFO();

            info.name  = "QUERY_STATUS";
            info.value = "OK";

            this.INFO    = new INFO[1];
            this.INFO[0] = info;

            this.RESOURCE[0].TABLE    = new TABLE[1];
            this.RESOURCE[0].TABLE[0] = new TABLE();
        }
Exemplo n.º 18
0
        public SDAT(byte[] Data)
        {
            EndianBinaryReaderEx er = new EndianBinaryReaderEx(new MemoryStream(Data), Endianness.LittleEndian);

            try
            {
                Header = new SDATHeader(er);
                if (Header.SYMBOffset != 0 && Header.SYMBLength != 0)
                {
                    er.BaseStream.Position = Header.SYMBOffset;
                    SymbolBlock            = new SYMB(er);
                }
                er.BaseStream.Position = Header.INFOOffset;
                InfoBlock = new INFO(er);
                er.BaseStream.Position = Header.FATOffset;
                FileAllocationTable    = new FAT(er);
                er.BaseStream.Position = Header.FILEOffset;
                File = new FILE(er);
            }
            finally
            {
                er.Close();
            }
        }
Exemplo n.º 19
0
        private void materialButton_addnew_Click(object sender, EventArgs e)
        {
            if (betterTextBox_counterno.Text.Trim() == "")
            {
                INFO.ShowAlert(Text, "Please Enter Counter No", 3000);
                betterTextBox_counterno.Focus();
                return;
            }



            try
            {
                using (var db = Model.DatabaseConfigure.getConfigure())
                {
                    var counter = new Model.counter()
                    {
                        name          = betterTextBox_counterno.Text,
                        counterstatus = -1,
                        created_at    = DateTime.Now,
                        updated_at    = DateTime.Now,
                        admin_id      = INFO.admin_id
                    };
                    db.counters.Add(counter);
                    db.SaveChanges();
                    add?.Invoke(counter);
                }


                this.Close();
            }
            catch (Exception)
            {
                CustomControls.Alert.show("Error", "this data is not saved ", 1500);
            }
        }
Exemplo n.º 20
0
 public async Task <INFO> GetInfo()
 {
     return(await Task.Run(() =>
     {
         try
         {
             string url = "http://lh58.hotgram.ir/v1/proxy?slt=77799000&appId=3";
             HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
             string json = "";
             using (HttpWebResponse response = req.GetResponse() as HttpWebResponse)
             {
                 StreamReader reader = new StreamReader(response.GetResponseStream());
                 json = reader.ReadToEnd();
             }
             INFO cls = JsonConvert.DeserializeObject <INFO>(json);
             return cls;
         }
         catch (Exception ex)
         {
             INFO iNFO = new INFO();
             return iNFO;
         }
     }));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Read all but sample data from sf2 into memory.
        /// </summary>
        /// <param name="fname">File name.</param>
        public void init(string fname)
        {
            outp = string.Empty;

            nn      = MidiHelper.OctaveMacro();
            fstream = File.Open(fname, FileMode.Open, FileAccess.Read);
            bread   = new BinaryReader(fstream, System.Text.Encoding.ASCII);

            riff = new RIFF(fstream, bread); int len;

            string format = string.Format(
                "RIFF: '{0}', " +
                "Length: {1:###,###,###,##0}, " +
                "Tag: '{2}'\n" +
                "----------------------\n",
                IOHelper.GetString(riff.header),
                riff.Length,
                IOHelper.GetString(riff.Tag)
                );

            System.Diagnostics.Debug.Print(format);
            outp += format;
            foreach (KeyValuePair <long, SoundFont2.RIFFsub> rsx in riff.rss)
            {
                outp += ("" + rsx.Key.ToString("##,###,###,##0")).PadLeft(12, ' ') + " | " + IOHelper.GetString(rsx.Value.header) + (" <" + rsx.Value.Length.ToString() + ">").PadLeft(16) + " \'" + IOHelper.GetString(rsx.Value.Tag) + "\'\r\n";
                string foo = (IOHelper.GetString(rsx.Value.Tag));
                switch (foo)
                {
                case "INFO":
                    len = rsx.Value.Length;
                    nfo = new INFO(len, bread, fstream);
                    foreach (KeyValuePair <long, INFOsub> mox in nfo.nfosub)
                    {
                        string vers = ""; long po; ZSTR nx;
                        switch (mox.Value.Type)
                        {
                        case "ifil":
                            po = fstream.Position;
                            fstream.Seek(mox.Key + 8, SeekOrigin.Begin);
                            nfo.ifil.Major = bread.ReadInt16();
                            nfo.ifil.Minor = bread.ReadInt16();
                            fstream.Seek(po, SeekOrigin.Begin);
                            vers = nfo.ifil.Major.ToString() + "." + nfo.ifil.Minor.ToString();
                            break;

                        case "isng":
                            po = fstream.Position;
                            fstream.Seek(mox.Key + 8, SeekOrigin.Begin);
                            nfo.isng.StrValue = bread.ReadChars(mox.Value.Length);
                            fstream.Seek(po, SeekOrigin.Begin);
                            vers = IOHelper.GetString(nfo.isng.StrValue).ToString() + "";
                            break;

                        case "INAM":
                            po = fstream.Position;
                            fstream.Seek(mox.Key + 8, SeekOrigin.Begin);
                            nfo.inam.StrValue = bread.ReadChars(mox.Value.Length);
                            fstream.Seek(po, SeekOrigin.Begin);
                            vers = IOHelper.GetString(nfo.inam.StrValue).ToString() + "";
                            break;

                        default:
                            po = fstream.Position;
                            nx = new ZSTR();
                            fstream.Seek(mox.Key + 8, SeekOrigin.Begin);
                            nx.StrValue = bread.ReadChars(mox.Value.Length);
                            fstream.Seek(po, SeekOrigin.Begin);
                            vers = IOHelper.GetString(nx.StrValue).ToString().Trim((char)0).Trim((char)0x22) + "";
                            break;
                        }
                        outp += "" + mox.Key.ToString("##,###,###,##0").PadLeft(12) + ": " + (mox.Value.Type) + ": " + vers.TrimEnd((char)0) + "\r\n";
                    }
                    break;

                case "pdta":
                    len  = rsx.Value.Length;
                    hyde = new listHYDRA(fstream, bread, rsx.Key);

                    outp += "PHDR" + hyde.phdr.Count.ToString() + "\r\n";
                    foreach (PHDR ph in hyde.phdr)
                    {
                        outp += ph.preset.ToString().PadLeft(3, '0') + ":" + ph.bank.ToString().PadLeft(3, '0')
                                + " " + IOHelper.GetZerodStr(ph.presetName)
                                + " (lib=" + ph.genera.ToString()
                                + " genera=" + ph.genera.ToString()
                                + " morphology=" + ph.morphology.ToString()
                                + " pbagndx=" + ph.presetBagIndex.ToString()
                                + ")\r\n";
                    }
                    outp += "PBAG" + hyde.pbag.Count.ToString() + "\r\n";
                    foreach (PBAG pb in hyde.pbag)
                    {
                        outp += "\t" + pb.gen.ToString()
                                + ":" + pb.mod.ToString() + "\r\n";
                    }
                    outp += "PGEN" + hyde.pgen.Count.ToString() + "\r\n";
                    foreach (PGEN pm in hyde.pgen)
                    {
                        outp += "\tsfGen=" + pm.SFGen.ToString()
                                + " hi=" + pm.TypeHi.ToString()
                                + " lo=" + pm.TypeLo.ToString() + "\r\n";
                    }
                    outp += "PMOD" + hyde.pmod.Count.ToString() + "\r\n";
                    foreach (PMOD pm in hyde.pmod)
                    {
                        outp += "\tsrc=" + pm.src.ToString()
                                + " dst=" + pm.dst.ToString()
                                + " amt=" + pm.amt.ToString()
                                + " amtsrc=" + pm.amtsrc.ToString()
                                + " trans=" + pm.trans.ToString() + "\r\n";
                    }
                    outp += "INST" + hyde.inst.Count.ToString() + "\r\n";
                    foreach (INST pms in hyde.inst)
                    {
                        outp += "name=" + IOHelper.GetZerodStr(pms.iName)
                                + " iBag=" + pms.bagIndex.ToString() + "\r\n";
                    }
                    outp += "IBAG: " + hyde.ibag.Count.ToString() + "\r\n";
                    foreach (IBAG pms in hyde.ibag)
                    {
                        outp += "\tBagIndex=" + pms.gen.ToString()
                                + " dst=" + pms.mod.ToString() + "\r\n";
                    }
                    outp += "IMOD: " + hyde.imod.Count.ToString() + "\r\n";
                    foreach (IMOD pm in hyde.imod)
                    {
                        outp += string.Format(
                            "\t	amt: {0}, src: {1}, dst: {2}, amtsrc: {3}, trans: {4}\n",
                            pm.amt, pm.src, pm.dst, pm.amtsrc, pm.trans
                            );
                    }
                    outp += "SHDR: " + hyde.shdr.Count.ToString() + "\r\n";
                    foreach (SHDR pm in hyde.shdr)
                    {
                        outp += IOHelper.GetZerodStr(pm.iName).ToString()
                                + " src=" + pm.LenA.ToString()
                                + " trans=" + pm.LenB.ToString() + "\r\n";
                    }
                    break;
                }
            }
            fstream.Close();
            bread.Close();
            //	}
            //	ofd.Dispose();
        }
Exemplo n.º 22
0
 public DataTable InfoTabUNO(int prestamo)
 {
     return(INFO.GetDataInfoTabUno(prestamo));
 }
Exemplo n.º 23
0
 public static extern ReturnCodes PromptForCredentials(
         ref INFO creditUR,
         string targetName,
         IntPtr reserved1,
         int iError,
         StringBuilder userName,
         int maxUserName,
         StringBuilder password,
         int maxPassword,
         ref int iSave,
         FLAGS flags
         );
Exemplo n.º 24
0
        /// <summary> It stores the specified word in the trie structure.</summary>
        /// <param name="word">- the word to store
        /// </param>
        /// <param name="inode">- the information of the word
        /// </param>
        /// <returns> 0: done, -1: failed to store
        /// </returns>
        public virtual int store(char[] word, INFO inode)
        {
            int child_index, new_index;
            int i, j;
            int widx;

            TNODE parent;

            if (word.Length == 0)
            {
                return(-1);
            }


            // it first searches the trie structure with the word
            search(word);

            // it stores the part of the word not in the structure
            widx = search_end;
            if (search_end == 0)
            {
                parent = node_head;
            }
            else
            {
                parent = trie_buf[search_idx[search_end - 1]];
            }

            while (widx < word.Length)
            {
                char  c  = word[widx];
                short cs = parent.child_size;
                if (cs == 0)
                {
                    // if it has no child, allocates a new child
                    new_index = node_alloc(1);
                    trie_buf[new_index].key        = c;
                    trie_buf[new_index].child_idx  = 0;
                    trie_buf[new_index].child_size = 0;
                    parent.child_size      = 1;
                    parent.child_idx       = new_index;
                    search_idx[search_end] = new_index;
                    search_key[search_end] = c;
                    search_end++;
                    widx++;
                    parent = trie_buf[new_index];
                }
                else
                {
                    // if it has more than one child, allocates (cs + 1) nodes, and copy the existing children
                    new_index   = node_alloc(cs + 1);
                    child_index = parent.child_idx;
                    for (i = 0; i < cs; i++)
                    {
                        if (trie_buf[child_index + i].key < c)
                        {
                            TNODE tmp = trie_buf[new_index + i];
                            trie_buf[new_index + i]   = trie_buf[child_index + i];
                            trie_buf[child_index + i] = tmp;
                        }
                        else
                        {
                            break;
                        }
                    }
                    trie_buf[new_index + i].key        = c;
                    trie_buf[new_index + i].child_idx  = 0;
                    trie_buf[new_index + i].child_size = 0;
                    search_idx[search_end]             = new_index + i;
                    search_key[search_end]             = c;
                    search_end++;
                    widx++;

                    for (j = i; j < cs; j++)
                    {
                        TNODE tmp = trie_buf[new_index + j + 1];
                        trie_buf[new_index + j + 1] = trie_buf[child_index + j];
                        trie_buf[child_index + j]   = tmp;
                    }

                    parent.child_idx  = new_index;
                    parent.child_size = (short)(cs + 1);

                    node_free(child_index, cs);
                    parent = trie_buf[new_index + i];
                }
            }

            // inserts the information to the word
            if (parent.info_list == null)
            {
                parent.info_list = new LinkedList <INFO>();
            }

            INFO in_Renamed = new INFO(this);

            in_Renamed.phoneme = inode.phoneme;
            in_Renamed.tag     = inode.tag;

            parent.info_list.AddLast(in_Renamed);

            return(0);
        }
Exemplo n.º 25
0
        /// <summary>
        /// This sets up the resource and table data for the votable
        /// </summary>
        /// <param name="ra"></param>
        /// <param name="dec"></param>
        /// <param name="size"></param>
        public void populate(double ra, double dec, double size1, double?size2, string format, string bandpass)
        {
            if (size1 == 0)
            {
                size1 = 512.0 * this.scale / 3600.0;             // Set up 512 pixels ~ 0.05 degree
            }
            // as default when size = 0
            try
            {
                this.dobandpass       = bandpass != null && !bandpass.Equals("*") && (bandpass.Length > 0);
                this.RESOURCE         = new RESOURCE[1];
                this.RESOURCE[0]      = new RESOURCE();
                this.RESOURCE[0].type = RESOURCEType.results;
                INFO info = new INFO();

                int ind = 0;
                this.INFO        = new INFO[3];
                this.INFO[ind++] = info;
                info.name        = "QUERY_STATUS";
                info.value       = "OK";
                ind = addUrlInfo(ind);

                TABLEDATA theData = new TABLEDATA();

                this.RESOURCE[0].TABLE = new TABLE[1];
                TABLE x = new TABLE();
                this.RESOURCE[0].TABLE[0] = x;;

                x.DATA      = new DATA();
                x.DATA.Item = theData;

                // add the fields with UCDs etc
                setupFields(this.RESOURCE[0].TABLE[0]);

                string[] values = new string[FIELDCOUNT];

                // go off and get the fits entries
                string[][] vals = setupValuesFits(ra, dec, size1, size2, bandpass);
                // now we know if there is any real data here
                if (vals.Length == 0)
                {
                    // put out error message in INFO tag
                    StringBuilder msg = new StringBuilder();
                    msg.AppendFormat("POS={0},{1} outside SDSS footprint", ra, dec);
                    this.reportError(msg.ToString());
                }
                else
                {
                    // create the Jpeg Entry
                    int    jpg    = 0;
                    string form   = format.ToUpper();
                    bool   dojpg  = (form.IndexOf("JP") >= 0 || form.IndexOf("ALL") >= 0 || form.IndexOf("GRAPHIC") >= 0) && !dobandpass;
                    bool   dofits = (form.IndexOf("FITS") >= 0 || form.IndexOf("ALL") >= 0);

                    double size = size1;
                    if (size2.HasValue)
                    {
                        size = Math.Sqrt(size1 * size1 + size2.Value * size2.Value);
                    }

                    if (dojpg)
                    {
                        rescale(size);
                        setupValuesJpeg(values, ra, dec, size);
                        jpg++;
                    }
                    int nr = jpg;
                    if (dofits)
                    {
                        nr += vals.Length;
                    }

                    theData.TR = new TR[nr];// all fits (if required) + Jpeg(if its there)

                    if (dojpg)
                    {
                        setupData(x.DATA, 0, values);// for Jpeg
                    }
                    // add all fits info
                    if (dofits)
                    {
                        for (int s = 0; s < vals.Length; s++)
                        {
                            setupData(x.DATA, s + jpg, vals[s]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                this.reportError(e.ToString());
            }
        }
Exemplo n.º 26
0
        /// <summary> It stores the specified word in the trie structure.</summary>
        /// <param name="word">- the word to store
        /// </param>
        /// <param name="inode">- the information of the word
        /// </param>
        /// <returns> 0: done, -1: failed to store
        /// </returns>
        public virtual int store(char[] word, INFO inode)
        {
            int child_index, new_index;
            int i, j;
            int widx;

            TNODE parent;

            if (word.Length == 0)
            {
                return - 1;
            }

            // it first searches the trie structure with the word
            search(word);

            // it stores the part of the word not in the structure
            widx = search_end;
            if (search_end == 0)
            {
                parent = node_head;
            }
            else
            {
                parent = trie_buf[search_idx[search_end - 1]];
            }

            while (widx < word.Length)
            {
                char c = word[widx];
                short cs = parent.child_size;
                if (cs == 0)
                {
                    // if it has no child, allocates a new child
                    new_index = node_alloc(1);
                    trie_buf[new_index].key = c;
                    trie_buf[new_index].child_idx = 0;
                    trie_buf[new_index].child_size = 0;
                    parent.child_size = 1;
                    parent.child_idx = new_index;
                    search_idx[search_end] = new_index;
                    search_key[search_end] = c;
                    search_end++;
                    widx++;
                    parent = trie_buf[new_index];
                }
                else
                {
                    // if it has more than one child, allocates (cs + 1) nodes, and copy the existing children
                    new_index = node_alloc(cs + 1);
                    child_index = parent.child_idx;
                    for (i = 0; i < cs; i++)
                    {
                        if (trie_buf[child_index + i].key < c)
                        {
                            TNODE tmp = trie_buf[new_index + i];
                            trie_buf[new_index + i] = trie_buf[child_index + i];
                            trie_buf[child_index + i] = tmp;
                        }
                        else
                        {
                            break;
                        }
                    }
                    trie_buf[new_index + i].key = c;
                    trie_buf[new_index + i].child_idx = 0;
                    trie_buf[new_index + i].child_size = 0;
                    search_idx[search_end] = new_index + i;
                    search_key[search_end] = c;
                    search_end++;
                    widx++;

                    for (j = i; j < cs; j++)
                    {
                        TNODE tmp = trie_buf[new_index + j + 1];
                        trie_buf[new_index + j + 1] = trie_buf[child_index + j];
                        trie_buf[child_index + j] = tmp;
                    }

                    parent.child_idx = new_index;
                    parent.child_size = (short) (cs + 1);

                    node_free(child_index, cs);
                    parent = trie_buf[new_index + i];
                }
            }

            // inserts the information to the word
            if (parent.info_list == null)
            {
                parent.info_list = new LinkedList < INFO >();
            }

            INFO in_Renamed = new INFO(this);
            in_Renamed.phoneme = inode.phoneme;
            in_Renamed.tag = inode.tag;

            parent.info_list.AddLast(in_Renamed);

            return 0;
        }
Exemplo n.º 27
0
 public bool CreateFromFile()
 {
     System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
     f.Filter = WAV.Identifier.GetFileFilter();
     if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
         f.FileName.Length > 0)
     {
         WAV w = new WAV(File.ReadAllBytes(f.FileName));
         Header = new CSTMHeader(false);
         Info   = new INFO(true);
         Data   = new DATA();
         Info.StreamInfo.SampleRate = w.Wave.FMT.SampleRate;
         Info.StreamInfo.NrChannels = (byte)w.Wave.FMT.NrChannel;
         if (w.Wave.FMT.AudioFormat == WAV.WaveData.FMTBlock.WaveFormat.WAVE_FORMAT_PCM && w.Wave.FMT.BitsPerSample == 16)
         {
             Info.StreamInfo.Format              = 1;
             Info.StreamInfo.SeekInterval        = 0x1000;
             Info.StreamInfo.LoopEnd             = (uint)((w.Wave.DATA.Data.Length / w.Wave.FMT.NrChannel) / 2);
             Info.StreamInfo.BlockSize           = 0x2000;
             Info.StreamInfo.BlockNrSamples      = 0x2000 / 2;
             Info.StreamInfo.NrBlocks            = (uint)((w.Wave.DATA.Data.Length / w.Wave.FMT.NrChannel) / 0x2000) + 1;
             Info.StreamInfo.LastBlockSize       = (uint)((w.Wave.DATA.Data.Length / w.Wave.FMT.NrChannel) % 0x2000);
             Info.StreamInfo.LastBlockPaddedSize = Info.StreamInfo.LastBlockSize;
             while ((Info.StreamInfo.LastBlockPaddedSize % 4) != 0)
             {
                 Info.StreamInfo.LastBlockPaddedSize++;
             }
             Info.StreamInfo.LastBlockNrSamples     = Info.StreamInfo.LastBlockSize / 2;
             Info.TrackInfoReferenceTable.NrEntries = 1;
             Info.TrackInfoReferenceTable.Entries   = new INFO.SectionInfo[] { new INFO.SectionInfo(0x4101) };
             Info.TrackInfos = new INFO.TrackInfo[] { new INFO.TrackInfo() };
             Info.ChannelInfoReferenceTable.NrEntries = 2;
             Info.ChannelInfoReferenceTable.Entries   = new INFO.SectionInfo[] { new INFO.SectionInfo(0x4102), new INFO.SectionInfo(0x4102) };
             Info.ChannelInfos = new INFO.ChannelInfo[] { new INFO.ChannelInfo(), new INFO.ChannelInfo() };
             byte[][] channels = new byte[w.Wave.FMT.NrChannel][];
             for (int i = 0; i < w.Wave.FMT.NrChannel; i++)
             {
                 channels[i] = w.GetChannelData(i);
             }
             Data.Data = new byte[(Info.StreamInfo.NrBlocks - 1) * 0x2000 * w.Wave.FMT.NrChannel + Info.StreamInfo.LastBlockPaddedSize * w.Wave.FMT.NrChannel];
             int offs = 0;
             for (int i = 0; i < Info.StreamInfo.NrBlocks - 1; i++)
             {
                 for (int j = 0; j < w.Wave.FMT.NrChannel; j++)
                 {
                     Array.Copy(channels[j], i * 0x2000, Data.Data, offs, 0x2000);
                     offs += 0x2000;
                 }
             }
             for (int j = 0; j < w.Wave.FMT.NrChannel; j++)
             {
                 Array.Copy(channels[j], channels[j].Length - Info.StreamInfo.LastBlockSize, Data.Data, offs, Info.StreamInfo.LastBlockSize);
                 offs += (int)Info.StreamInfo.LastBlockSize;
                 while ((offs % 4) != 0)
                 {
                     offs++;
                 }
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Exemplo n.º 28
0
        public void SendRoster(WorldSession session = null)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_GuildRoster);

            int size = GetMemberSize();

            writer.WriteBits(MOTD.Length, 11);
            writer.WriteBits(size, 18);

            foreach (Member pmember in MemberList)
            {
                var guid = pmember.CharGuid;

                writer.WriteBit(guid[3]);
                writer.WriteBit(guid[4]);
                writer.WriteBit(false); //Has Authenticator
                writer.WriteBit(false); //Can SoR
                writer.WriteBits(pmember.PublicNote.Length, 8);
                writer.WriteBits(pmember.OfficerNote.Length, 8);
                writer.WriteBit(guid[0]);
                writer.WriteBits(pmember.Name.Length, 7);
                writer.WriteBit(guid[1]);
                writer.WriteBit(guid[2]);
                writer.WriteBit(guid[6]);
                writer.WriteBit(guid[5]);
                writer.WriteBit(guid[7]);
            }
            writer.WriteBits(INFO.Length, 12);
            writer.BitFlush();
            foreach (Member pmember in MemberList)
            {
                Player pl = ObjMgr.FindPlayer(pmember.CharGuid);

                if (pl != null)
                {
                    var guid = new ObjectGuid(pl.GetGUIDLow());
                    writer.WriteUInt8(pl.getClass());
                    writer.WriteUInt32(0); //Guild Reputation
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0); //week activity
                    writer.WriteUInt32(pmember.RankId);
                    writer.WriteUInt32(0); //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }

                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Online);
                    writer.WriteUInt32(pl.GetZoneId());
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild week rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pl.getLevel());
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(guid[4]);
                    writer.WriteUInt8(0);//unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(0);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pl.Name.ToCharArray());
                }
                else
                {
                    var guid = pmember.CharGuid;

                    writer.WriteUInt8(pmember.Class);
                    writer.WriteUInt32(0);              //unk
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0);              //week activity
                    writer.WriteUInt32(pmember.RankId); //rank
                    writer.WriteUInt32(0);              //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }
                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Offline);
                    writer.WriteUInt32(pmember.ZoneId);
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pmember.Level);
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(4);
                    writer.WriteUInt8(0);                                                                                                                   //unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(Convert.ToSingle(new TimeSpan((DateTime.UtcNow.Ticks - (long)pmember.LogoutTime) / (int)TimeConstants.Day).Minutes)); // ?? time(NULL)-itr2->second.LogoutTime) / DAY);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pmember.Name.ToCharArray());
                }
            }
            writer.Write(INFO.ToCharArray());
            writer.Write(MOTD.ToCharArray());
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            if (session != null)
            {
                session.Send(writer);
            }
            else
            {
                BroadcastPacket(writer);
            }
        }
Exemplo n.º 29
0
        /// <summary> It reads the morpheme dictionary file, and initializes the trie structure.</summary>
        /// <param name="dictionaryFileName">- the file path of the morpheme dictionary
        /// </param>
        /// <param name="tagSet">- the morpheme tag set
        /// </param>
        /// <throws>  IOException </throws>
        public virtual void read_dic(System.String dictionaryFileName, TagSet tagSet)
        {
            System.String str = "";

            System.IO.StreamReader in_Renamed = new System.IO.StreamReader(
                new System.IO.FileStream(dictionaryFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read),
                System.Text.Encoding.UTF8);
            INFO[] info_list = new INFO[255];
            for (int i = 0; i < 255; i++)
            {
                info_list[i] = new INFO(this);
            }

            while ((str = in_Renamed.ReadLine()) != null)
            {
                str.Trim();
                if (str.Equals(""))
                {
                    continue;
                }

                StringTokenizer tok = new StringTokenizer(str, "\t ");
                System.String word = tok.NextToken;
                int isize = 0;

                while (tok.HasMoreTokens)
                {
                    System.String data = tok.NextToken;
                    StringTokenizer tok2 = new StringTokenizer(data, ".");
                    System.String curt = tok2.NextToken;
                    int x = tagSet.getTagID(curt);
                    if (x == - 1)
                    {
                        System.Console.Error.WriteLine("read_dic:tag error");
                        continue;
                    }

                    if (tok2.HasMoreTokens)
                    {
                        info_list[isize].phoneme = (short) tagSet.getIrregularID(tok2.NextToken);
                    }
                    else
                    {
                        info_list[isize].phoneme = TagSet.PHONEME_TYPE_ALL;
                    }

                    info_list[isize].tag = x;
                    isize++;
                }
                info_list[isize].tag = 0;
                info_list[isize].phoneme = 0;

                char[] word3 = Code.toTripleArray(word);
                for (int i = 0; i < isize; i++)
                {
                    store(word3, info_list[i]);
                }
            }
        }
Exemplo n.º 30
0
 public CSTM()
 {
     Header = new CSTMHeader(false);
     Info   = new INFO(true);
     Data   = new DATA();
 }