示例#1
0
	public static void Main()
	{
	  Read r = new Read(1 , 2, 3);
	  Console.WriteLine("Value of x {0}", r.x);
	  Console.WriteLine("Value of y {0}", r.y);
	  Console.WriteLine("Value of z {0}", r.z);
	}
        public void ReadUserPostsTest()
        {
            // act
            string input = "Bob";
            var user = new User { UserId = Guid.NewGuid(), Username = input };

            var output = new StringBuilder();
            output.AppendLine("Good game though. (1 minute(s) ago)");
            output.AppendLine("Damn! We lost! (2 minute(s) ago)");

            var messages = new List<Message>
            {
                new Message { Description = "Good game though.", PostedDt = DateTime.UtcNow.AddMinutes(-1)},
                new Message { Description = "Damn! We lost!", PostedDt = DateTime.UtcNow.AddMinutes(-2)}
            };

            _userManagerMock.Setup(x => x.GetUserByUsername(user.Username, true)).Returns(user);
            _messageManagerMock.Setup(x => x.GetMessages(user)).Returns(messages);

            var read = new Read(_userManagerMock.Object, _messageManagerMock.Object);

            // actual
            var actual = read.Perform(input);

            // assert
            Assert.AreEqual(actual, output.ToString());
            _messageManagerMock.Verify(x => x.GetMessages(user), Times.Once);
        }
示例#3
0
文件: Chirps.cs 项目: dolittle/Chirp
 public static MessageChirped BuildCorrespondingMessageChirpedEventFrom(Read.Streams.Chirp chirp)
 {
     return new MessageChirped(chirp.ChirpedBy.ChirperId)
                {
                    ChirpId = chirp.Id,
                    ChirpedBy = chirp.ChirpedBy.ChirperId,
                    Content = chirp.Content,
                    ChirpedAt = chirp.ChirpedAt,
                };
 }
        public void ReadInvalidUserPosts()
        {
            // act
            string input = "Alice";

            _userManagerMock.Setup(x => x.GetUserByUsername("Alice", true)).Throws(new NullReferenceException("Alice does not exists!"));

            var read = new Read(_userManagerMock.Object, _messageManagerMock.Object);

            // actual
            var actual = read.Perform(input);

            // assert
            Assert.AreEqual(actual, "Alice does not exists!");
            _messageManagerMock.Verify(x => x.GetMessages(It.IsAny<User>()), Times.Never);
        }
示例#5
0
        public List<SelectListItem> GetCategoryDropDownList()
        {
            var categoriesDropDownList = new List<SelectListItem>();

            var read = new Read();
            var categories = read.GetAllCategories();

            foreach (var cat in categories)
            {
                var e = new SelectListItem();

                e.Text = cat.CategoryName;
                e.Value = cat.CategoryID.ToString();

                categoriesDropDownList.Add(e);
            }

            return categoriesDropDownList;
        }
        public override string ToString()
        {
            r = (Read)base.Tag;

            Binding myBinding = new Binding("variable");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = r;
            txtvar.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("filename");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = r;
            cmbfilename.SetBinding(ComboBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("maxdigits");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = r;
            txtmax.SetBinding(TextBox.TextProperty, myBinding3);

            Binding myBinding4 = new Binding("option");
            myBinding4.Mode = BindingMode.TwoWay;
            myBinding4.Source = r;
            txtopt.SetBinding(ComboBox.TextProperty, myBinding4);

            Binding myBinding5 = new Binding("attempts");
            myBinding5.Mode = BindingMode.TwoWay;
            myBinding5.Source = r;
            txtatt.SetBinding(TextBox.TextProperty, myBinding5);

            Binding myBinding6 = new Binding("timeout");
            myBinding6.Mode = BindingMode.TwoWay;
            myBinding6.Source = r;
            txttimeout.SetBinding(TextBox.TextProperty, myBinding6);

            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = r;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);


            return base.ToString();
        }
示例#7
0
        /// <summary>
        /// Attempts to acquire read lock.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="availableSiteList">The available site list.</param>
        /// <returns></returns>
        public static List<Site> AquireReadLock(Read action, List<Site> availableSiteList)
        {
            var lockedSites = new List<Site>();

            foreach (Site tempSite in availableSiteList)
            {
                var variable = tempSite.GetVariable(action.VariableIdInt);

                var result = variable.GetReadLock(action.Transaction);

                //we got the lock
                if (result.Contains(action.Transaction))
                {
                    lockedSites.Add(tempSite);
                    break;
                }
            }

            return lockedSites;
        }
示例#8
0
文件: Form1.cs 项目: Zeroi9/cwbackup
        // This is to backup current characters.db
        private void button1_Click(object sender, EventArgs e)
        {
            Read directoryReader = new Read();
            string CubeDirectory = directoryReader.directory;

            // this is Backup current characters
            // Current time
            DateTime time = DateTime.Now;
            string today = "MMM ddd d HH:mm yyyy";
            today = time.ToString(today);
            today = today.Replace(" ", "_");
            today = today.Replace(":", ".");
            // Generate new characters backup
            string backupName = "characters/characters_" + today.Replace(" ", "_");
            int fileExists = 1;
            int temp = 0;
            /*
             This do { } will:
             * increase temp by 1
             * check if file exists, like characters_date_temp.db, until it doesn't exist, then do { } is done.
             */
            do
            {
                temp++;
                if (File.Exists("backups/" + backupName + ".db"))
                {
                    backupName += "_" + temp.ToString();
                }
                else
                    fileExists = 0;
            }
            while (fileExists == 1);
            temp = 0;
            // Copy characters.db from cubedirectory to backups folder
            File.Copy(CubeDirectory + "\\Save\\characters.db", "backups/" + backupName + ".db");
            // refresh list box
            loadListBox(1);
            // messagebox
            MessageBox.Show("Your characters has been backed up with the name: " + backupName);
        }
 public IEnumerable <CandidateAllele> FindCandidates(Read read, string refChromosome, string chromosomeName)
 {
     return(ProcessCigarOps(read, refChromosome, read.Position, chromosomeName));
 }
示例#10
0
        private void AddReferenceDatabaseBasicHelper(ArdbVersion version)
        {
            AddReferenceDatabase ardb = new AddReferenceDatabase(version);
            DatabaseAddResult    result;

            // Build and add the sample PackageDatabase
            PackageDatabase source = PackageDatabaseTests.BuildDefaultSample("V1");

            result = CallAddUniqueMembers(ardb, source);

            // Verify at least something was added
            int ardbCountFirstAdd = ardb.Count;

            Assert.IsTrue(result.WasMemberAdded[0].Value);

            // Add the sample again; verify nothing was added
            source = PackageDatabaseTests.BuildDefaultSample("V2");
            result = CallAddUniqueMembers(ardb, source);
            Assert.IsFalse(result.WasMemberAdded[0].Value);
            Assert.AreEqual(ardbCountFirstAdd, ardb.Count);

            // Add a namespace with a private class; verify nothing added
            source = PackageDatabaseTests.BuildDefaultSample("V3");
            MutableSymbol diagnostics = source.MutableRoot.FindByFullName(BuildDiagnosticsNamespaceFor(source.Identity.PackageName), PackageDatabaseTests.SEPARATOR_CHAR);
            MutableSymbol internalNs  = diagnostics.AddChild(new MutableSymbol("Internal", SymbolType.Namespace));

            internalNs.AddChild(new MutableSymbol("Tracer", SymbolType.Class)
            {
                Modifiers = SymbolModifier.Internal
            });
            result = CallAddUniqueMembers(ardb, source);
            Assert.IsFalse(result.WasMemberAdded[0].Value);
            Assert.AreEqual(ardbCountFirstAdd, ardb.Count);

            // Add a new public class (existing namespace); verify it is added
            source      = PackageDatabaseTests.BuildDefaultSample("V4");
            diagnostics = source.MutableRoot.FindByFullName(BuildDiagnosticsNamespaceFor(source.Identity.PackageName), PackageDatabaseTests.SEPARATOR_CHAR);
            diagnostics.AddChild(new MutableSymbol("TraceWatch", SymbolType.Class)
            {
                Modifiers = SymbolModifier.Public | SymbolModifier.Static
            });
            result = CallAddUniqueMembers(ardb, source);
            Assert.IsTrue(result.WasMemberAdded[0].Value);
            Assert.IsTrue(result.WasMemberAdded[result.WasMemberAdded.Length - 1].Value);
            Assert.AreNotEqual(ardbCountFirstAdd, ardb.Count);

            // Verify a query [expect Diagnostics. to match Logger, Memory, and TraceWatch
            ardb.ConvertToImmutable();
            VerifyQueryResults(ardb, version);

            // Double-convert ARDB. Verify queries still work correctly.
            ardb.ConvertToImmutable();
            VerifyQueryResults(ardb, version);

            // Round trip to string; verify query still right, count matches
            string sampleArdbFilePath = "Sample.ardb.txt";

            Write.ToFile(ardb.WriteText, sampleArdbFilePath);
            AddReferenceDatabase reloaded = new AddReferenceDatabase(version);

            Read.FromFile(reloaded.ReadText, sampleArdbFilePath);

            VerifyQueryResults(reloaded, version);
            Assert.AreEqual(ardb.Count, reloaded.Count);

            string sampleRewriteArdbFilePath = "Sample.Rewrite.ardb.txt";

            Write.ToFile(reloaded.WriteText, sampleRewriteArdbFilePath);
            Assert.AreEqual(File.ReadAllText(sampleArdbFilePath), File.ReadAllText(sampleRewriteArdbFilePath));
        }
示例#11
0
 int On(Read req) => value;
示例#12
0
文件: Form1.cs 项目: Zeroi9/cwbackup
        // Load all backups into the listboxes.
        private void loadListBox(int type)
        {
            // Character backup
            if (type == 1)
            {
                // since listbox1 is always loaded on form load, check if directories exists - if not, create them
                if (!Directory.Exists("backups") || !Directory.Exists("backups/worlds") || !Directory.Exists("backups/characters"))
                {
                    Directory.CreateDirectory("backups");
                    Directory.CreateDirectory("backups\\worlds");
                    Directory.CreateDirectory("backups\\characters");
                }
                // since this is called on every time we do something related to characters backups, we don't
                // want the same backups to be listed more than once, so we clear the listbox.
                listBox1.Items.Clear();
                // get all files from backups/characters/.
                string[] saves = Directory.GetFiles("backups\\characters");
                // for each file, remove backups/characters/ and add it to the listbox.
                foreach (string file in saves)
                {
                    listBox1.Items.Add(file.Replace("backups\\characters\\", ""));
                }
            }
                // World backup
            else if (type == 2)
            {
                Read directoryReader = new Read();
                string CubeDirectory = directoryReader.directory;
                // Get all files in the save directory
                string[] saves = Directory.GetFiles(CubeDirectory + "/Save");

                // char array
                char[] fileChar;
                // foreach file in the save directory, split the / so the last index in
                // filePath contains the filename.
                foreach (string file in saves)
                {
                    int temp = 0;
                    string[] filePath = file.Split('/');
                    foreach (string word in filePath)
                    {
                        temp++;
                    }
                    // replace the Save\ from the filename.
                    string fileName = filePath[temp - 1].Replace("Save\\", "");
                    fileChar = fileName.ToCharArray();
                    // if filename doesn't begins with m(map) or c(characters), add them to the listbox.
                    if (fileChar[0] != 'm' && fileChar[0] != 'c' && fileName != "worlds.db")
                        listBox2.Items.Add(fileName);
                }
            }
            else
            {
                // this is load listbox3(world backups)
                listBox3.Items.Clear();
                // get files from backup folder
                string[] saves = Directory.GetFiles("backups\\worlds");
                // foreach file, add them to the list and replace the path.
                foreach (string file in saves)
                {
                    listBox3.Items.Add(file.Replace("backups\\worlds\\", ""));
                }
            }
        }
示例#13
0
        private static IList <IDictionary <string, object> > RelationshipCounts(TokenRead tokens, Read read, Anonymizer anonymizer)
        {
            IList <IDictionary <string, object> > relationshipCounts = new List <IDictionary <string, object> >();
            IDictionary <string, object>          relationshipCount  = new Dictionary <string, object>();

            relationshipCount["count"] = read.CountsForRelationshipWithoutTxState(-1, -1, -1);
            relationshipCounts.Add(relationshipCount);

            IList <NamedToken> labels = Iterators.asList(tokens.LabelsGetAllTokens());

            tokens.RelationshipTypesGetAllTokens().forEachRemaining(t =>
            {
                long count = read.CountsForRelationshipWithoutTxState(-1, t.id(), -1);
                IDictionary <string, object> relationshipTypeCount = new Dictionary <string, object>();
                relationshipTypeCount.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id()));
                relationshipTypeCount.put("count", count);
                relationshipCounts.Add(relationshipTypeCount);
                foreach (NamedToken label in labels)
                {
                    long startCount = read.CountsForRelationshipWithoutTxState(label.id(), t.id(), -1);
                    if (startCount > 0)
                    {
                        IDictionary <string, object> x = new Dictionary <string, object>();
                        x.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id()));
                        x.put("startLabel", anonymizer.Label(label.name(), label.id()));
                        x.put("count", startCount);
                        relationshipCounts.Add(x);
                    }
                    long endCount = read.CountsForRelationshipWithoutTxState(-1, t.id(), label.id());
                    if (endCount > 0)
                    {
                        IDictionary <string, object> x = new Dictionary <string, object>();
                        x.put("relationshipType", anonymizer.RelationshipType(t.name(), t.id()));
                        x.put("endLabel", anonymizer.Label(label.name(), label.id()));
                        x.put("count", endCount);
                        relationshipCounts.Add(x);
                    }
                }
            });

            return(relationshipCounts);
        }
        public StaticPage GetPageByID(int staticPageID)
        {
            var read = new Read();

            return read.GetPageByID(staticPageID);
        }
        public List<Post> GetAllPostSummaries()
        {
            var read = new Read();

            var posts = read.GetAllPostSummaries();

            return posts;
        }
示例#16
0
        /// <summary>
        /// Retrieves primary key of just added entity
        /// </summary>
        /// <typeparam name="T">Type of primary key</typeparam>
        /// <param name="qr">Channel</param>
        /// <param name="keyedAddition">Performed addition</param>
        /// <returns>Primary key</returns>
        public static T Key <T>(this Read <QueryChannel <Query> > qr, IAddition <IPrimaryKey <T> > keyedAddition)
        {
            var pr = qr.Feature();

            return(pr.Key(keyedAddition));
        }
        public List<Post> GetPostsByTagID(int tagID)
        {
            var read = new Read();
            var posts = read.GetPostsByTagID(tagID);

            foreach (var p in posts)
            {
                p.HashTags = read.GetTagsByPostID(p.PostID);
            }

            return posts;
        }
示例#18
0
        /// <summary>
        /// Retrieves query builder for ORM query channel
        /// </summary>
        /// <typeparam name="T">Type of entity</typeparam>
        /// <param name="qr">Query channel</param>
        /// <returns>Query builder</returns>
        public static IQueryFor <T> Get <T>(this Read <QueryChannel <Query> > qr) where T : class
        {
            var pr = qr.Feature();

            return(new QueryBuilder <T>(pr));
        }
示例#19
0
        /// <summary>
        /// Retrieves query builder for ORM query channel
        /// </summary>
        /// <typeparam name="T">Type of entity</typeparam>
        /// <param name="qr">Query channel</param>
        /// <returns>Query builder</returns>
        public static IQueryable <T> All <T>(this Read <QueryChannel <Query> > qr) where T : class
        {
            var pr = qr.Feature();

            return(pr.GetSet <T>());
        }
示例#20
0
 public StudentViewModel ReadModel()
 {
     return(Read.ModelFromPage());
 }
示例#21
0
        private string[] GenMasterFileKingPower(MySqlDataReader aRead)
        {
            Int32  i = 0, j = 0;
            double ldoPriceStart;

            string[]        lsData = new string[3000];
            string          lsSQL = "", lsVouDate = "", lsDay = "", lsTRoomName = "";
            string          lsData1_10 = "", lsData11_23 = "", lsMemID = "", lsMemName = "";
            string          lsUserName = lsIni.GetString("thahr30", "username", "janepop");
            string          lsPassword = lsIni.GetString("thahr30", "password", "Ekartc2c5");
            string          lsServer   = lsIni.GetString("thahr30", "serverdatabasename", "localhost");
            string          lsDatabase = lsIni.GetString("thahr30", "databasename", "localhost");
            string          StrConn    = "Data Source=" + lsServer + ";Database=" + lsDatabase + ";User ID=" + lsUserName + ";Password="******"";
            MySqlConnection Conn       = new MySqlConnection(StrConn);
            MasterKingPower lsMaster   = new MasterKingPower();
            double          ldoMulti   = 0;

            try
            {
                //lsIniT.CreateTblTypeRoom(lsGdb.Gdb);
                lsMaster.ReVat         = 1.07;
                lsMaster.ShopCode      = lsIni.GetString("kingpower", "shopcode", "0");
                lsMaster.Std_Cate_Code = lsIni.GetString("kingpower", "std_cate_code", "0");
                lsMaster.Branch_Code   = lsIni.GetString("kingpower", "branch_code", "0");
                lsMaster.ShpBnd_Code   = lsIni.GetString("kingpower", "shpbnd_code", "0");
                lsMaster.Currency_code = lsIni.GetString("kingpower", "currency_code", "0");
                lsMaster.Rate          = lsIni.GetString("kingpower", "rate", "0");
                lsMaster.Unit_Code     = lsIni.GetString("kingpower", "unit_code", "0");
                lsMaster.VatRate       = lsIni.GetString("thahr30", "vatrate", "0");
                lsMaster.UStoBaht      = lsIni.GetString("thahr30", "USTOBAHT", "0");
                ldoMulti = Convert.ToDouble(lsIni.GetString("kingpower", "ratekingpower", "15.00"));
                //lsMaster.ReVat = lsMaster.Vat_Rate;
                Conn.Open();
                lsDay     = Convert.ToString(System.DateTime.Now.Day - 1);
                lsVouDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + lsDay;
                if (aRead.HasRows)
                {
                    //lsVat_Rate = lsMaster.lsVatRate;
                    lsMaster.Vat_Type     = lsIni.GetString("kingpower", "vat_type", "1");
                    lsMaster.ReQuest_Date = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00");
                    //lsMaster.ReQuest_Date = "2006-09-28";
                    lsMaster.Request_Exc_Vat  = "";
                    lsMaster.Request_Inc_Vat  = "";
                    lsMaster.RequestEFF_SDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00") + " " + System.DateTime.Now.Hour.ToString("00") + ":" + System.DateTime.Now.Minute.ToString("00") + ":" + System.DateTime.Now.Second.ToString("00");

                    /*if ((System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00") + " " + System.DateTime.Now.Hour.ToString("00") + ":" + System.DateTime.Now.Minute.ToString("00") + ":" + System.DateTime.Now.Second.ToString("00")) > (System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59"))
                     * {
                     *  lsMaster.RequestEFF_EDate = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59";
                     *  lsMaster.Ref_Price_Date = "2006-09-27";
                     * }
                     * else
                     * {*/
                    lsMaster.RequestEFF_EDate = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59";
                    lsMaster.Ref_Price_Date   = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27";
                    //}
                    //lsMaster.RequestEFF_SDate = "2006-09-28 00:00:00";
                    //lsMaster.RequestEFF_EDate = "2011-09-27 23:59:59";
                    //lsMaster.RequestEFF_EDate = DateTime.Now.AddYears(1).tos;

                    lsMaster.Ref_Price     = "7.0";
                    lsMaster.Ref_Price_SRC = "Don Muang";
                    //lsMaster.Ref_Price_Date = "2006-09-27";
                    lsMaster.Ref_Code_1 = "";
                    lsMaster.Ref_Code_2 = "";
                    lsMaster.Ref_Code_3 = "";
                    lsMaster.Ref_Code_4 = "";
                    lsMaster.Ref_Code_5 = "";
                    while (aRead.Read())
                    {
                        lsMemID = aRead.GetValue(0).ToString();
                        if (lsMemID == "-")
                        {
                            lsSQL = "";
                        }
                        lsSQL = "select * From memberpricelist Where memid = '" + lsMemID + "' and flagsendkingpower = '1'";
                        MySqlCommand    Comm = new MySqlCommand(lsSQL, Conn);
                        MySqlDataReader Read;
                        Read = Comm.ExecuteReader();
                        if (Read.HasRows)
                        {
                            j = 0;
                            while (Read.Read())
                            {
                                i++;
                                if (Read["flagoldkingpower"].ToString() == "1")
                                {
                                    lsMaster.Trans_Type = "1";
                                }
                                else
                                {
                                    lsMaster.Trans_Type = "2";
                                }
                                lsSQL     = aRead.GetValue(1).ToString();
                                lsMemName = aRead.GetValue(1).ToString();
                                lsMaster.Ref_Price_SRC = lsMemName;
                                ldoPriceStart          = Convert.ToDouble(aRead.GetValue(12));
                                lsSQL = Convert.ToString(aRead.GetValue(12));
                                decimal cc = Convert.ToDecimal(aRead.GetValue(12));
                                //ldoPriceStart = (Convert.ToDouble(aRead.GetValue(12)) * Convert.ToDouble(lsMaster.UStoBaht));
                                if (Read["remark"].ToString() == "US$")
                                {
                                    ldoPriceStart = (Convert.ToDouble(Read["pricestart"]) * Convert.ToDouble(lsMaster.UStoBaht));
                                }
                                else
                                {
                                    ldoPriceStart = Convert.ToDouble(Read["pricestart"]);
                                }
                                ldoPriceStart = (ldoPriceStart * ldoMulti) / 100;
                                //decimal bbb = Convert.ToDecimal(ldoPriceStart);
                                decimal aa = decimal.Round(Convert.ToDecimal(ldoPriceStart * lsMaster.ReVat), 2); //lsMaster.Request_Inc_Vat = Convert.ToString(decimal.Round(Convert.ToDecimal(ldoPriceStart), 2));
                                //lsMaster.Request_Inc_Vat = ldoPriceStart.ToString("0.00");
                                //lsMaster.Vat_Type;
                                //lsMaster.Request_Inc_Vat = ldoPriceStart.ToString("0.00");
                                if (lsMaster.Vat_Type == "2")
                                {
                                    decimal aaa = Convert.ToDecimal(ldoPriceStart + (ldoPriceStart * Convert.ToDouble(lsMaster.VatRate) / 100));
                                    lsMaster.Request_Inc_Vat = aaa.ToString("0.00");
                                    lsMaster.Request_Exc_Vat = ldoPriceStart.ToString("0.00");
                                }
                                else
                                {
                                    lsMaster.Request_Inc_Vat = Convert.ToString(aa);
                                    lsMaster.Request_Exc_Vat = Convert.ToString(ldoPriceStart);
                                }
                                //lsMaster.Request_Inc_Vat = lsMaster.Request_Inc_Vat;
                                lsMaster.Ref_Price = lsMaster.Request_Exc_Vat;
                                lsTRoomName        = lsIniT.SelectInitial(lsIniT.TblTypeRoom, Read["plcode"].ToString(), Initial.WhereSelect.aCodetoName);
                                j++;
                                lsData1_10  = lsMaster.ShopCode + "|" + lsMaster.Std_Cate_Code + "|" + lsMemID + Read["plcode"].ToString() + "|" + lsMemName + "[" + lsTRoomName + "]" + "|" + lsMaster.ShpBnd_Code + "|" + lsMaster.BarCode + "|" + lsMaster.Trans_Type + "|" + lsMaster.Vat_Type + "|" + lsMaster.VatRate + "|" + lsMaster.Unit_Code;
                                lsData11_23 = lsMaster.ReQuest_Date + "|" + lsMaster.Request_Exc_Vat + "|" + lsMaster.Request_Inc_Vat + "|" + lsMaster.RequestEFF_SDate + "|" + lsMaster.RequestEFF_EDate + "|" + lsMaster.Ref_Price + "|" + lsMaster.Ref_Price_SRC + "|" + lsMaster.Ref_Price_Date + "|" + lsMaster.Ref_Code_1 + "|" + lsMaster.Ref_Code_2 + "|" + lsMaster.Ref_Code_3 + "|" + lsMaster.Ref_Code_4 + "|" + lsMaster.Ref_Code_5;
                                lsData[i]   = lsData1_10 + "|" + lsData11_23;
                            }
                        }
                        Read.Close();
                    }
                }
                Conn.Close();
            }
            catch (Exception e)
            {
                string ls = "äÁèÊÒÁÒöàµÃÕÂÁ¢éÍÁÙÅ Print ä´é ";
                lsGdb.WriteLogError(ls, e, "", "GenMasterFileKingPower ");
                //MessageBox.Show(ls + " " + eAcc.Message.ToString(), eAcc.Source.ToString(), MessageBoxButtons.OK);
            }
            return(lsData);
        }
示例#22
0
        public static void Run(ILogger logger)
        {
            OnlineClient client = Bootstrap.Client(logger);

            logger.LogInformation("Executing CRUD customer functions to API");

            CustomerCreate create = new CustomerCreate()
            {
                CustomerName = "Joshua Granley",
                Active       = false,
            };

            Task <OnlineResponse> createTask = client.Execute(create);

            createTask.Wait();
            OnlineResponse createResponse = createTask.Result;
            Result         createResult   = createResponse.Results[0];

            string customerId = createResult.Data[0].Element("CUSTOMERID").Value;
            int    recordNo   = int.Parse(createResult.Data[0].Element("RECORDNO").Value);

            Console.WriteLine("Created inactive customer ID " + customerId);

            CustomerUpdate update = new CustomerUpdate()
            {
                CustomerId = customerId,
                Active     = true,
            };

            Task <OnlineResponse> updateTask = client.Execute(update);

            updateTask.Wait();

            Console.WriteLine("Updated customer ID " + customerId + " to active");

            Read read = new Read()
            {
                ObjectName = "CUSTOMER",
                Fields     =
                {
                    "RECORDNO",
                    "CUSTOMERID",
                    "STATUS",
                },
                Keys =
                {
                    recordNo,
                }
            };

            Task <OnlineResponse> readTask = client.Execute(read);

            readTask.Wait();

            Console.WriteLine("Read customer ID " + customerId);

            CustomerDelete delete = new CustomerDelete()
            {
                CustomerId = customerId,
            };

            Task <OnlineResponse> deleteTask = client.Execute(delete);

            deleteTask.Wait();

            Console.WriteLine("Deleted customer ID " + customerId);

            LogManager.Flush();
        }
        public List<Post> GetPostsByAmount(int amount)
        {
            var read = new Read();
            var posts = read.GetPostsByAmount(amount);

            foreach (var p in posts)
            {
                p.HashTags = read.GetTagsByPostID(p.PostID);
            }

            return posts;
        }
示例#24
0
        /// <summary>
        /// Publishes a stream of data for a given schema
        /// </summary>
        /// <param name="request"></param>
        /// <param name="responseStream"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task ReadStream(ReadRequest request, IServerStreamWriter <Record> responseStream,
                                              ServerCallContext context)
        {
            var schema       = request.Schema;
            var limit        = request.Limit;
            var limitFlag    = request.Limit != 0;
            var jobId        = request.JobId;
            var recordsCount = 0;

            Logger.SetLogPrefix(request.JobId);
            Logger.Info($"Publishing records for schema: {schema.Name}");

            try
            {
                var conn            = Utility.GetSqlConnection(jobId);
                var filesByRootPath = _server.Settings.GetAllFilesByRootPath();

                if (string.IsNullOrWhiteSpace(schema.Query))
                {
                    // schema is not query based so we can stream each file as it is loaded
                    var rootPaths  = _server.Settings.GetRootPathsFromQuery(Utility.GetDefaultQuery(schema));
                    var rootPath   = rootPaths.First();
                    var files      = filesByRootPath[rootPath.RootPathName()];
                    var schemaName = Constants.SchemaName;
                    var tableName  = string.IsNullOrWhiteSpace(rootPath.Name)
                        ? new DirectoryInfo(rootPath.RootPath).Name
                        : rootPath.Name;
                    if (files.Count > 0)
                    {
                        // load file and then stream file one by one
                        foreach (var file in files)
                        {
                            Utility.LoadDirectoryFilesIntoDb(Utility.GetImportExportFactory(rootPath.Mode), conn,
                                                             rootPath,
                                                             tableName, schemaName, new List <string> {
                                file
                            }, true);

                            var records = Read.ReadRecords(context, schema, jobId);

                            foreach (var record in records)
                            {
                                // stop publishing if the limit flag is enabled and the limit has been reached or the server is disconnected
                                if ((limitFlag && recordsCount == limit) || !_server.Connected)
                                {
                                    break;
                                }

                                // publish record
                                await responseStream.WriteAsync(record);

                                recordsCount++;
                            }
                        }
                    }
                    else
                    {
                        Utility.DeleteDirectoryFilesFromDb(conn, tableName, schemaName, Utility.GetImportExportFactory(rootPath.Mode), rootPath, files);
                    }
                }
                else
                {
                    // schema is query based
                    var rootPaths = _server.Settings.GetRootPathsFromQuery(schema.Query);

                    Logger.Info(
                        $"Query root paths {JsonConvert.SerializeObject(rootPaths.Select(r => r.RootPathName()).ToList(), Formatting.Indented)}");

                    Logger.Info($"Begin loading all files.");

                    // schema is query based so everything in query needs to be loaded first
                    var hasRecords = true;
                    foreach (var rootPath in rootPaths)
                    {
                        var files      = filesByRootPath[rootPath.RootPathName()];
                        var schemaName = Constants.SchemaName;
                        var tableName  = string.IsNullOrWhiteSpace(rootPath.Name)
                            ? new DirectoryInfo(rootPath.RootPath).Name
                            : rootPath.Name;
                        if (files.Count > 0)
                        {
                            Utility.LoadDirectoryFilesIntoDb(Utility.GetImportExportFactory(rootPath.Mode), conn,
                                                             rootPath,
                                                             tableName, schemaName, files, true);
                        }
                        else
                        {
                            hasRecords = false;
                            Utility.DeleteDirectoryFilesFromDb(conn, tableName, schemaName, Utility.GetImportExportFactory(rootPath.Mode), rootPath, files);
                        }
                    }

                    Logger.Info("Completed loading all files.");

                    if (hasRecords)
                    {
                        var records = Read.ReadRecords(context, schema, jobId);

                        foreach (var record in records)
                        {
                            // stop publishing if the limit flag is enabled and the limit has been reached or the server is disconnected
                            if ((limitFlag && recordsCount == limit) || !_server.Connected)
                            {
                                Logger.Info($"Stopping read - limit reached: {limitFlag && recordsCount == limit}, server disconnected: {!_server.Connected}");
                                break;
                            }

                            // publish record
                            await responseStream.WriteAsync(record);

                            recordsCount++;
                        }
                    }
                }

                Logger.Info($"Published {recordsCount} records");

                foreach (var rootPath in _server.Settings.RootPaths)
                {
                    var files = filesByRootPath[rootPath.RootPathName()];
                    switch (rootPath.CleanupAction)
                    {
                    case Constants.CleanupActionDelete:
                        foreach (var file in files)
                        {
                            Logger.Info($"Deleting file {file}");
                            Utility.DeleteFileAtPath(file, rootPath, _server.Settings, true);
                        }

                        break;

                    case Constants.CleanupActionArchive:
                        foreach (var file in files)
                        {
                            Logger.Info($"Archiving file {file} to {rootPath.ArchivePath}");
                            Utility.ArchiveFileAtPath(file, rootPath, _server.Settings);
                        }

                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e, e.Message, context);
            }
        }
        public void SetUp()
        {
            Createrepo = new Create();
            Readrepo = new Read();
            Deleterepo = new Delete();
            Updaterepo = new Update();
            dropdownrepo = new DropDown();

            userID = "b75da91b - e39a - 42ce - b2f0 - 4834eda139e1";
        }
        private List <ProductGroups> getGroups()
        {
            List <ProductGroups> groups = Read.getProductGroups();

            return(groups);
        }
        private void FirstRead(byte[] streamData, int readBytes, char[] characters)
        {
            Encoding encoding = selector.GetEncoding(streamData);
            decoder = encoding.GetDecoder();
            int theOffset = selector.ByteCount(encoding);

            int decoded = decoder.GetChars(streamData, theOffset, readBytes - theOffset , characters, 0);
            myCallbackDelegate(characters, decoded);
            currentRead = ReadFurther;
        }
示例#28
0
 public EmployeeViewModel()
 {
     Employees       = new BindableCollection <EmployeeModel>(Read.Employees());
     Positions       = new BindableCollection <string>(Read.Dropdown("EmployeePosition"));
     universalHelper = new UniversalHelper();
 }
示例#29
0
文件: Form1.cs 项目: Zeroi9/cwbackup
 // This is to backup a world
 private void button4_Click(object sender, EventArgs e)
 {
     Read directoryReader = new Read();
     string CubeDirectory = directoryReader.directory;
     if (listBox2.GetItemText(listBox2.SelectedItem) == "")
     {
         MessageBox.Show("You need to select a world!");
     }
     // this is Backup world
     // Generate world backup
     string backupName = "worlds/" + listBox2.GetItemText(listBox2.SelectedItem);
     int fileExists = 1;
     int temp = 0;
     /*
      This do { } will:
      * increase (int) temp by 1
      * first run: if file exists (backups/worlds/world.db), change it to (temp)world.db.
      * second run: if file exists(backups/worlds/(temp)world.db), increase temp by 1.
      * When the file doesn't exist, set fileExists to 0 and the do { } is done.
      */
     do
     {
         temp++;
         if (File.Exists("backups/" + backupName))
         {
             backupName = "worlds/" + listBox2.GetItemText(listBox2.SelectedItem);
             backupName = backupName.Replace("world_", "(" + temp + ")" + "world_");
         }
         else
             fileExists = 0;
     }
     while (fileExists == 1);
     temp = 0;
     // Backup the world
     File.Copy(CubeDirectory + "\\Save\\" + listBox2.GetItemText(listBox2.SelectedItem), "backups/" + backupName);
     // refresh list box
     loadListBox(3);
     // Show a messagebox
     MessageBox.Show("Your world has been backed up with the name: " + backupName);
 }
示例#30
0
        public Player()
        {
            InitializeComponent();

            Reader = new Read();
        }
示例#31
0
        /// <summary>
        /// Retrieves specified query feature for
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="r"></param>
        /// <returns></returns>
        public static T PleaseFeature <T>(this Read r) where T : QueryFeature
        {
            var mux = r as IQueryMultiplexer;

            return(mux.GetFeature <T>());
        }
示例#32
0
        static void Main(string[] args)
        {
            //Memoria memoria = new Memoria();
            //Pilha pilha = new Pilha();
            Processador processador = new Processador();
            tipo        num1        = new Inteiro(3);
            tipo        num2        = new Inteiro(5);
            tipo        num3        = new Inteiro(8);


            //Instrucoes instruc = new Push(processador.pilha,num1);
            //instruc.executar();

            //Instrucoes instruc5 = new Store(processador.memoria, processador.pilha, "opa");
            //instruc5.executar();

            //Instrucoes instruc4 = new Pop(processador.pilha);
            //instruc4.executar();

            string[] programa = System.IO.File.ReadAllLines(@"C:/Users/dougl/Desktop/Teste.txt");
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha[0] == "Label")
                {
                    Instrucoes intruc3 = new Label(processador.pilha, linha[1], i, processador.labels);
                    intruc3.executar();
                }
            }
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha.Length == 2)
                {
                    switch (linha[0])
                    {
                    case "Push":
                        if (linha[1] == "true")
                        {
                            tipo       parametro = new Booleano(true);
                            Instrucoes intruc    = new Push(processador.pilha, parametro);
                            intruc.executar();
                        }
                        else if (linha[1] == "false")
                        {
                            tipo       parametro = new Booleano(false);
                            Instrucoes intruc1   = new Push(processador.pilha, parametro);
                            intruc1.executar();
                        }
                        else
                        {
                            tipo       parametro = new Inteiro(int.Parse(linha[1]));
                            Instrucoes intruc2   = new Push(processador.pilha, parametro);
                            intruc2.executar();
                        }
                        break;

                    case "Load":
                        Instrucoes intruc4 = new Load(processador.memoria, processador.pilha, linha[1]);
                        intruc4.executar();
                        break;

                    case "Store":
                        Instrucoes intruc5 = new Store(processador.memoria, processador.pilha, linha[1]);
                        intruc5.executar();
                        break;

                    case "GoTo":
                        GoTo intruc6 = new GoTo(processador.labels, linha[1], processador.pilha);
                        intruc6.executar(i);
                        i = intruc6.index;
                        break;

                    case "GoTof":
                        GoTof intruc7 = new GoTof(processador.labels, linha[1], processador.pilha);
                        intruc7.executar(i);
                        i = intruc7.index;
                        break;
                    }
                }
                else if (linha.Length == 1)
                {
                    switch (linha[0])
                    {
                    case "Pop":
                        Instrucoes intruc = new Pop(processador.pilha);
                        intruc.executar();
                        break;

                    case "Add":
                        Instrucoes intruc2 = new Add(processador.pilha);
                        intruc2.executar();
                        break;

                    case "Sub":
                        Instrucoes intruc3 = new Sub(processador.pilha);
                        intruc3.executar();
                        break;

                    case "EQ":
                        Instrucoes intruc4 = new EQ(processador.pilha);
                        intruc4.executar();
                        break;

                    case "GE":
                        Instrucoes intruc5 = new GE(processador.pilha);
                        intruc5.executar();
                        break;

                    case "GT":
                        Instrucoes intruc6 = new GT(processador.pilha);
                        intruc6.executar();
                        break;

                    case "LE":
                        Instrucoes intruc7 = new LE(processador.pilha);
                        intruc7.executar();
                        break;

                    case "LT":
                        Instrucoes intruc8 = new LT(processador.pilha);
                        intruc8.executar();
                        break;

                    case "NE":
                        Instrucoes intruc9 = new NE(processador.pilha);
                        intruc9.executar();
                        break;

                    case "Print":
                        Instrucoes intruc10 = new Print(processador.pilha);
                        intruc10.executar();
                        break;

                    case "Read":
                        Instrucoes intruc11 = new Read(processador.pilha);
                        intruc11.executar();
                        break;

                    case "end":
                        i = programa.Length;
                        break;
                    }
                }
            }

            //Instrucoes instruc3 = new Push(processador.pilha, num2);
            //instruc3.executar();

            //Instrucoes instruc6 = new Load(processador.memoria, processador.pilha, "opa");
            //instruc6.executar();

            //Instrucoes instruc7 = new Add(processador.pilha);
            //instruc7.executar();

            //Instrucoes instruc9 = new Push(processador.pilha, num3);
            //instruc9.executar();

            //Instrucoes instruc8 = new EQ(processador.pilha);
            //instruc8.executar();

            //Instrucoes instruc2 = new Print(processador.pilha);
            //instruc2.executar();

            Console.ReadKey();
        }
示例#33
0
 FindVariantResults(List <VariantSite> variantsFromVcf, Read read)
 {
     return(FindVariantResults(variantsFromVcf, read.BamAlignment));
 }
示例#34
0
 public override object Reader(Read reader)
 {
     return(reader.readData.ReadValue(key));
 }
示例#35
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            string strSheetName = "";
            long   lngCount     = 0;
            Stream myStream     = null;

            DG.Rows.Clear();
            if (uctxtbranchName.Text == "")
            {
                MessageBox.Show("Branch Name Cannot be Empty");
                uctxtbranchName.Focus();
                return;
            }
            lblDisplay.Text = "Please ..Wait.... File is Loading";
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "Excel files (*.xlsx)|*.xlsx";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            string strFileName = "", strPath = "";
                            int    selRaw = 0, i = 1;
                            strPath     = openFileDialog1.FileName;
                            strFileName = strPath.Substring(strPath.LastIndexOf('\\') + 1);
                            strPath     = strPath.Replace(strFileName, "");

                            var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(strPath, strFileName)));
                            //var data = Mayhedi.Office.Excel.Reader.Read.ReadObjFromExel(stream);
                            if (strSelection == "TA")
                            {
                                strSheetName = "Sales Target";
                            }
                            else if (strSelection == "CT")
                            {
                                string strdate = dtefromDate.Value.ToString("yyyy");
                                strSheetName = "Collection Target-" + strdate;
                            }
                            else if (strSelection == "MC")
                            {
                                strSheetName = "Credit Limit";
                            }
                            var data = Read.ReadObjFromExel(stream, strSheetName);

                            string[] value = data.Split('~');

                            foreach (string word in value)
                            {
                                if (word != "")
                                {
                                    DG.AllowUserToAddRows = true;
                                    selRaw = Convert.ToInt16(DG.RowCount.ToString());
                                    selRaw = selRaw - 1;
                                    DG.Rows.Add(1);
                                    string[] value1 = word.Split('!');
                                    DG[0, selRaw].Value  = Utility.GetMerzeNameFromTeritorryCode(strComID, value1[0].ToString());
                                    DG[1, selRaw].Value  = Utility.GetLedgerNameFromTeritorryCode(strComID, value1[0].ToString());
                                    DG[2, selRaw].Value  = Math.Round(Utility.Val(value1[1]), 2);
                                    DG[3, selRaw].Value  = Math.Round(Utility.Val(value1[2]), 2);
                                    DG[4, selRaw].Value  = Math.Round(Utility.Val(value1[3]), 2);
                                    DG[5, selRaw].Value  = Math.Round(Utility.Val(value1[4]), 2);
                                    DG[6, selRaw].Value  = Math.Round(Utility.Val(value1[5]), 2);
                                    DG[7, selRaw].Value  = Math.Round(Utility.Val(value1[6]), 2);
                                    DG[8, selRaw].Value  = Math.Round(Utility.Val(value1[7]), 2);
                                    DG[9, selRaw].Value  = Math.Round(Utility.Val(value1[8]), 2);
                                    DG[10, selRaw].Value = Math.Round(Utility.Val(value1[9]), 2);
                                    DG[11, selRaw].Value = Math.Round(Utility.Val(value1[10]), 2);
                                    DG[12, selRaw].Value = Math.Round(Utility.Val(value1[11]), 2);
                                    DG[13, selRaw].Value = Math.Round(Utility.Val(value1[12]), 2);
                                    //if (selRaw % 2 == 0)
                                    //{
                                    //    DG.Rows[selRaw].DefaultCellStyle.BackColor = Color.Beige;
                                    //}
                                    //else
                                    //{
                                    //    DG.Rows[selRaw].DefaultCellStyle.BackColor = Color.White;
                                    //}
                                    lngCount += 1;
                                }
                            }
                            lblTotalrecord.Text = "Total Count:" + lngCount.ToString();
                            lblDisplay.Text     = "";
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#36
0
 public override object Reader(Read reader, object defaultData)
 {
     return(reader.readData.ReadValue(key, defaultData));
 }
        protected IEnumerable <CandidateAllele> ExtractSnvsFromOperation(Read alignment, string refChromosome, int opStartIndexInRead, uint operationLength, int opStartIndexInReference, string chromosomeName)
        {
            var candidateSingleNucleotideAlleles = new List <CandidateAllele>();
            var variantLengthSoFar        = 0;
            var interveningRefLengthSoFar = 0;
            var openLeft = false;

            for (var i = 0; i < operationLength; i++)
            {
                var qualityGoodEnough = alignment.Qualities[opStartIndexInRead + i] >= _minimumBaseCallQuality;

                var readBase = alignment.Sequence[opStartIndexInRead + i];
                if (opStartIndexInReference + i >= refChromosome.Length)
                {
                    break;
                }
                var refBase = refChromosome[opStartIndexInReference + i];

                var atEndOfOperation            = i == (operationLength - 1);
                var startingMnvAtEndOfOperation = (atEndOfOperation && variantLengthSoFar == 0);

                //Do not create/extend a variant if the quality isn't good enough or the allele or ref is an N
                if ((AlleleHelper.GetAlleleType(readBase) == AlleleType.N) || (AlleleHelper.GetAlleleType(refBase) == AlleleType.N) || !qualityGoodEnough)
                {
                    FlushVariant(alignment, refChromosome, opStartIndexInRead + i - variantLengthSoFar,
                                 opStartIndexInReference + i - variantLengthSoFar, chromosomeName, variantLengthSoFar,
                                 interveningRefLengthSoFar, candidateSingleNucleotideAlleles, openLeft, true); // note we ended because of poor quality, mark open ended
                    variantLengthSoFar        = 0;
                    interveningRefLengthSoFar = 0;
                    openLeft = true;
                }
                else
                {
                    if (BasesMatch(refBase, readBase))
                    {
                        if (ShouldBuildUpMNV(variantLengthSoFar, interveningRefLengthSoFar, true) &&
                            !startingMnvAtEndOfOperation) //Don't build up an MNV if we're on the last base of operation
                        {
                            variantLengthSoFar++;
                            interveningRefLengthSoFar++;
                        }
                        else
                        {
                            FlushVariant(alignment, refChromosome, opStartIndexInRead + i - variantLengthSoFar,
                                         opStartIndexInReference + i - variantLengthSoFar, chromosomeName, variantLengthSoFar,
                                         interveningRefLengthSoFar, candidateSingleNucleotideAlleles, openLeft, false);
                            variantLengthSoFar        = 0;
                            interveningRefLengthSoFar = 0;
                            openLeft = false;
                        }
                    }
                    else
                    {
                        if (ShouldBuildUpMNV(variantLengthSoFar, interveningRefLengthSoFar, false) &&
                            !startingMnvAtEndOfOperation) //Don't build up an MNV if we're on the last base of operation
                        {
                            variantLengthSoFar++;
                            interveningRefLengthSoFar = 0;
                        }
                        else
                        {
                            FlushVariant(alignment, refChromosome, opStartIndexInRead + i - variantLengthSoFar,
                                         opStartIndexInReference + i - variantLengthSoFar,
                                         chromosomeName, variantLengthSoFar, interveningRefLengthSoFar,
                                         candidateSingleNucleotideAlleles, openLeft, false);
                            variantLengthSoFar        = 1;
                            interveningRefLengthSoFar = 0;
                            openLeft = false;
                        }
                    }
                }
            }
            //Flush if we've gotten to the end
            FlushVariant(alignment, refChromosome, opStartIndexInRead + ((int)operationLength) - variantLengthSoFar,
                         opStartIndexInReference + ((int)operationLength) - variantLengthSoFar, chromosomeName, variantLengthSoFar,
                         interveningRefLengthSoFar, candidateSingleNucleotideAlleles, openLeft, false);


            return(candidateSingleNucleotideAlleles);
        }
示例#38
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     return(Read.Sign(from, ofs, ref dst));
 }
        /// <summary>
        /// Create a new candidate allele from alignment and add support.  Exposed only for unit testing.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="chromosome"></param>
        /// <param name="coordinate"></param>
        /// <param name="reference"></param>
        /// <param name="alternate"></param>
        /// <param name="alignment"></param>
        /// <param name="startIndexInRead"></param>
        /// <param name="wellAnchoredAnchorSize"></param>
        /// <returns></returns>
        public static CandidateAllele Create(AlleleCategory type, string chromosome, int coordinate, string reference,
                                             string alternate, Read alignment, int startIndexInRead, int wellAnchoredAnchorSize)
        {
            var candidate = new CandidateAllele(chromosome, coordinate, reference, alternate, type);
            var alleleSupportDirection = GetSupportDirection(candidate, alignment, startIndexInRead);

            candidate.SupportByDirection[(int)alleleSupportDirection]++;
            var anchor = Math.Min(coordinate - alignment.Position, alignment.EndPosition - coordinate);

            if (anchor > Math.Min(wellAnchoredAnchorSize - 1, alternate.Length - 1))
            {
                candidate.WellAnchoredSupportByDirection[(int)alleleSupportDirection]++;
            }

            if (alignment.IsCollapsedRead())
            {
                ReadCollapsedType?collapsedType = alignment.GetReadCollapsedType(alleleSupportDirection);
                if (collapsedType.HasValue) // ignore non-proper read pairs
                {
                    switch (collapsedType.Value)
                    {
                    case ReadCollapsedType.DuplexNonStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.DuplexNonStitched]++;
                        break;

                    case ReadCollapsedType.DuplexStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.DuplexStitched]++;
                        break;

                    case ReadCollapsedType.SimplexStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexStitched]++;
                        break;

                    case ReadCollapsedType.SimplexReverseStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexStitched]++;
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexReverseStitched]++;
                        break;

                    case ReadCollapsedType.SimplexForwardStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexStitched]++;
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexForwardStitched]++;
                        break;

                    case ReadCollapsedType.SimplexNonStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexNonStitched]++;
                        break;

                    case ReadCollapsedType.SimplexReverseNonStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexNonStitched]++;
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexReverseNonStitched]++;
                        break;

                    case ReadCollapsedType.SimplexForwardNonStitched:
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexNonStitched]++;
                        candidate.ReadCollapsedCountsMut[(int)ReadCollapsedType.SimplexForwardNonStitched]++;
                        break;

                    default:
                        throw new Exception();
                    }
                }
            }
            return(candidate);
        }
示例#40
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     dst.x += Convert.NanosInDay * Read.DecimalFixed(from, ofs, ofs + 2);
     return(ofs + 2);
 }
示例#41
0
 public static void AddPacket(byte i, Read p)
 {
     net.packets.Add(i, p);
 }
示例#42
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     // TODO: Rangecheck for length > 5
     return(Read.Component(from, ofs, length, ref dst, Convert.NanosInDay));
 }
        public Post GetPostByID(int id)
        {
            var read = new Read();

            var post = read.GetPostByID(id);

            post.HashTags = read.GetTagsByPostID(post.PostID);

            return post;
        }
示例#44
0
文件: Form1.cs 项目: Zeroi9/cwbackup
 // Load character backup
 private void button2_Click(object sender, EventArgs e)
 {
     // Get selected backup
     string backup = listBox1.GetItemText(listBox1.SelectedItem);
     // If no backup selected, show a messagebox
     if (backup == "")
     {
         MessageBox.Show("Select a backup file first!");
     }
     else
     {
         Read directoryReader = new Read();
         string CubeDirectory = directoryReader.directory;
         // If the file exists in cubedirectory
         if (File.Exists(CubeDirectory + "\\Save\\characters.db"))
         {
             // delete it
             File.Delete(CubeDirectory + "\\Save\\characters.db");
         }
         // Copy from backups to cubedirectory saves.
         File.Copy("backups/characters/" + backup, CubeDirectory + "\\Save\\characters.db");
         MessageBox.Show("The selected backup has been restored!");
     }
 }
        public Reader(Callback callback)
        {
            this.currentRead = FirstRead;
            this.myCallbackDelegate = callback;

            selector = new EncodingSelector();
        }
示例#46
0
文件: CfCard.cs 项目: vanloc0301/qms3
 public static bool read()
 {
     byte[] bytes = new byte[0x20];
     myread = new Read();
     byte[] myid = new byte[0x100];
     DIS_UII.ToString();
     myid = Distributor.CfCard.CfCard.myid;
     StringBuilder builder = new StringBuilder
     {
         Capacity = 0x100
     };
     StringBuilder passwordbuffer = new StringBuilder
     {
         Capacity = 4
     };
     passwordbuffer.Append("");
     new StringBuilder { Capacity = 2 }.Append("");
     StringBuilder uErrorCode = new StringBuilder
     {
         Capacity = 2
     };
     byte[] buffer3 = new byte[0x100];
     bool flag = false;
     char ptr = '\0';
     for (int i = 0; i < 3; i++)
     {
         if (RmuReadData(hReader, passwordbuffer, 3, ref ptr, 12, myid, ref buffer3[0], uErrorCode, flagCrc) == 1)
         {
             MessageBeep(0);
             flag = true;
             for (int j = 0; j < 0x18; j++)
             {
                 bytes[j] = buffer3[j];
             }
             break;
         }
     }
     if (!flag)
     {
         return false;
     }
     if (!flag)
     {
         return false;
     }
     myread.CarNum = Encoding.Default.GetString(bytes, 4, 6);
     myread.Cardtype = ((char)bytes[0]).ToString();
     myread.Status = ((char)bytes[20]).ToString();
     myread.date = bytes[12].ToString("x2") + bytes[13].ToString("x2") + bytes[14].ToString("x2");
     return true;
 }
        public List<HashTag> GetAllTags()
        {
            var read = new Read();

            return read.GetAllTags();
        }
示例#48
0
 public void Init()
 {
     instance = new Read();
 }
示例#49
0
文件: CfCard.cs 项目: vanloc0301/qms3
        //(string strUid)
        //返回id一部分
        public static bool read()
        {
            byte[] readdata;
            readdata = new byte[32];
            myread = new Read();
            byte[] byUUID = new byte[256];
            string strUid = DIS_UII.ToString();
            byUUID = myid;
            StringBuilder DIS_ReadData;
            DIS_ReadData = new StringBuilder();
            DIS_ReadData.Capacity = 256;

            StringBuilder PassWord;
            PassWord = new StringBuilder();
            PassWord.Capacity = 4;
            PassWord.Append("");

            StringBuilder Ptr;
            Ptr = new StringBuilder();
            Ptr.Capacity = 2;
            Ptr.Append("");

            StringBuilder uErrorCode;
            uErrorCode = new StringBuilder();
            uErrorCode.Capacity = 2;

            string strRead = "";
            byte[] byRead = new byte[256];

            bool status = false;
            char cPtr = (char)0;

            //            char cPtr2 = (char)4;
             //           char cPtr3 = (char)8;
              //          char cPtr4 = (char)10;
            for (int i = 0; i <3; i++)
            {

                if (RmuReadData(hReader, PassWord, 3, ref cPtr, 12, byUUID, ref byRead[0], uErrorCode, flagCrc) == 1)
                {
                    //  ASCIIEncoding asciiEncoding = new ASCIIEncoding();
                    //strRead = asciiEncoding.GetString(byRead, 0, byRead.Length);
                    // strRead =

                    //  listBox2.Items.Add(strRead);
                    MessageBeep(0);
                    status = true;
                    for (int k = 0; k < 24; k++)
                        readdata[k] = byRead[k];
                    break;
                }

            }
            if (status == false)
                return false;
            //status = false;
            //for (int i = 0; i < 3; i++)
            //{

            //    if (RmuReadData(hReader, PassWord, 3, ref cPtr2, 8, byUUID, ref byRead[0], uErrorCode, flagCrc) == 1)
            //    {
            //        // ASCIIEncoding asciiEncoding = new ASCIIEncoding();
            //        // strRead = asciiEncoding.GetString(byRead, 0, byRead.Length);

            //        //  listBox2.Items.Add(strRead);
            //        MessageBeep(0);
            //        status = true;
            //        for (int k = 8; k < 16; k++)
            //            readdata[k] = byRead[k - 8];
            //        break;
            //    }

            //}
            //if (status == false)
            //    return false;
            //status = false;
            //for (int i = 0; i < 3; i++)
            //{

            //    if (RmuReadData(hReader, PassWord, 3, ref cPtr3, 4, byUUID, ref byRead[0], uErrorCode, flagCrc) == 1)
            //    {
            //        // ASCIIEncoding asciiEncoding = new ASCIIEncoding();
            //        // strRead = asciiEncoding.GetString(byRead, 0, byRead.Length);

            //        //  listBox2.Items.Add(strRead);
            //        MessageBeep(0);
            //        status = true;
            //        for (int k = 16; k < 20; k++)
            //            readdata[k] = byRead[k - 16];
            //        break;
            //    }

            //}
            //if (status == false)
            //    return false;
            //status = false;

            //for (int i = 0; i <3; i++)
            //{

            //    if (RmuReadData(hReader, PassWord, 3, ref cPtr4, 4, byUUID, ref byRead[0], uErrorCode, flagCrc) == 1)
            //    {
            //        // ASCIIEncoding asciiEncoding = new ASCIIEncoding();
            //        // strRead = asciiEncoding.GetString(byRead, 0, byRead.Length);

            //        //  listBox2.Items.Add(strRead);
            //        MessageBeep(0);
            //        status = true;
            //        for (int k = 20; k < 24; k++)
            //            readdata[k] = byRead[k - 20];
            //        break;
            //    }
            //}
            if (status == false)
                return false;
            else
            {
                myread.CarNum = System.Text.Encoding.Default.GetString(readdata, 4, 6);
                myread.Cardtype = ((char)readdata[0]).ToString();
                myread.Status = ((char)readdata[20]).ToString();
             //   byReceive[i].ToString("x2");
                myread.date = readdata[12].ToString("x2") + readdata[13].ToString("x2") + readdata[14].ToString("x2");
               //     MessageBox.Show(myread.date);
                return true;
            }
        }
        public List<Post> GetAllPostsByCategory(int categoryID)
        {
            var read = new Read();
            var posts = read.GetAllPostsByCategory(categoryID);

            foreach (var p in posts)
            {
                p.HashTags = read.GetTagsByPostID(p.PostID);
            }

            return posts;
        }
示例#51
0
文件: Form1.cs 项目: Zeroi9/cwbackup
        // Load world backup
        private void button5_Click(object sender, EventArgs e)
        {
            // Get the selected world.
            string backup = listBox3.GetItemText(listBox3.SelectedItem);
            string backup_full = listBox3.GetItemText(listBox3.SelectedItem);
            // If no world selected, show a messagebox
            if (backup == "")
            {
                MessageBox.Show("Select a backup file first!");
            }
                // Else
            else
            {
                // this is a bad way but I don't know how to do it otherwise lol
                // Take the world name into a character array
                char[] loadWorldName = backup.ToCharArray();

                int startIndex = 0;
                int endIndex = 0;
                // For each character in the worldname:
                for (int i = 0; i < loadWorldName.Length; i++)
                {
                    // if character equals to a (, set the startIndex to that character index.
                    if (loadWorldName[i] == '(')
                        startIndex = i;
                    // if character equals to a ), set the endIndex to that character index.
                    if (loadWorldName[i] == ')')
                        endIndex = i;
                }

                // if the end index isn't 0 (that means that there's 2 or more backups of the same world
                if (endIndex != 0)
                {
                    // Replace the ( ) and everything inbetween with *.
                    while (startIndex <= endIndex)
                    {
                        loadWorldName[startIndex] = '*';
                        startIndex++;
                    }
                }

                // give backup string the worldname variable.
                backup = new string(loadWorldName);
                // Remove *.
                backup = backup.Replace("*", "");
                // Input could be (1)world_123.db, output is world_123.db.

                // New Read object to get the CubeDirectory
                Read directoryReader = new Read();
                string CubeDirectory = directoryReader.directory;
                // If the file exists in the cubedirectory
                if (File.Exists(CubeDirectory + "\\Save\\" + backup))
                {
                    // delete it
                    File.Delete(CubeDirectory + "\\Save\\" + backup);
                }
                // copy the backup to the cubedirectory
                File.Copy("backups/worlds/" + backup_full, CubeDirectory + "\\Save\\" + backup);
                // messagebox
                MessageBox.Show("Your backup has been restored!");
            }
        }
示例#52
0
        private static IList <IDictionary <string, object> > NodeCounts(TokenRead tokens, Read read, Anonymizer anonymizer)
        {
            IList <IDictionary <string, object> > nodeCounts = new List <IDictionary <string, object> >();
            IDictionary <string, object>          nodeCount  = new Dictionary <string, object>();

            nodeCount["count"] = read.CountsForNodeWithoutTxState(-1);
            nodeCounts.Add(nodeCount);

            tokens.LabelsGetAllTokens().forEachRemaining(t =>
            {
                long count = read.CountsForNodeWithoutTxState(t.id());
                IDictionary <string, object> labelCount = new Dictionary <string, object>();
                labelCount.put("label", anonymizer.Label(t.name(), t.id()));
                labelCount.put("count", count);
                nodeCounts.Add(labelCount);
            });

            return(nodeCounts);
        }
示例#53
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     dst.day = Read.DecimalFixed(from, ofs, ofs + 2);
     return(ofs + 2);
 }
        public List<HashTag> GetTagsByPostId(int postID)
        {
            var read = new Read();

            return read.GetTagsByPostID(postID);
        }
示例#55
0
        private void sortButton_Click(object sender, EventArgs e)
        {
            if (file == string.Empty)
            {
                MessageBox.Show("No file selected");
                return;
            }

            string check = System.IO.File.ReadAllText(file);
            Read reader = new Read(file);
            mainCore = reader.setCore();
            ignoredLines = reader.setIgnoredLines();

            checkAndPrint(mainCore);

            Printer printer = new Printer(file, mainCore, ignoredLines);
            printer.makeFile();
            MessageBox.Show("Finished");
        }
示例#56
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     // TODO: Range check
     return(Read.Component(from, ofs, 2, ref dst, Convert.NanosInSecond));
 }
示例#57
0
 public override int Parse(String from, int ofs, ref ParsedValue dst)
 {
     return(Read.Component(from, ofs, length, ref dst, scale));
 }
示例#58
0
        /// <summary>
        /// For creation of new Custom Field is used latest WorkOrder.
        /// By default creation, update, deletion of Custom Fields is disabled.
        /// To enable creation, update, deletion mode for Custom Fields set isCreateUpdateDelete = true.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="isCreateUpdateDelete">by default is false</param>
        public static void CRUDExample(CorrigoService service,
                                       bool isCreateUpdateDelete = false)
        {
            if (service == null)
            {
                return;
            }

            //
            // Get Custom Field Descriptor with properties (Custom Field: JIRA LINK; Domain: Work Order; Data Type : URL)
            //
            CustomFieldDescriptor customFieldDescriptor = GetCustomFieldDescriptor(service, "JIRA LINK", ActorType.WO, CfType.Url);

            if (customFieldDescriptor == null || !(customFieldDescriptor.Id > 0))
            {
                Console.WriteLine("Custom Field Descriptor is undefined");
                return;
            }

            //Get latest WO
            CorrigoEntity[] latestWO = GetLatestWOs(service, 1);
            if (!latestWO.Any())
            {
                Console.WriteLine("No existing Work Order was found");
                return;
            }

            //
            // Retrieve Custom field specified by descriptor for given Work Order.
            //
            CustomField2 cf = Read.Retrieve(service, latestWO[0], customFieldDescriptor);

            if (cf == null && isCreateUpdateDelete)
            {
                //
                // Create Custom field specified by descriptor for given Work Order.
                //
                cf = Create.Execute(service, latestWO[0], customFieldDescriptor);
            }

            if (cf != null && isCreateUpdateDelete)
            {
                cf = Read.Retrieve(service, latestWO[0], customFieldDescriptor);

                //
                // Update Custom field
                //
                Update.Execute(service, cf);

                //
                // Delete Custom Field
                //
                Delete.Execute(service, cf.Id);

                //Update.Restore(service, cf); // CustomField2 is not restorable.
            }

            //
            // Retrive 10 Custom Fields with Data Type : URL
            //
            Read.RetrieveByQuery(service); // retrieve is limited to 10 records
        }
        static void Main(string[] args)
        {
            //Test test = new Test();
               // test.Start();

            Read r = new Read();
            Central central = r.ReadFile();
            Simulation(central, 5000);
            Console.WriteLine("Koniec symulacji");
            System.Console.Read();
        }
        public List<StaticPage> GetAllPageSummaries()
        {
            var read = new Read();

            return read.GetAllPageSummaries();
        }