コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="src"></param>
        /// <returns></returns>
        public override CyNetwork GetNetwork(CyNetwork src)
        {
            string connStr = ConfigurationManager.ConnectionStrings["qwerty"].ConnectionString;

            using (var conn = new SqlConnection(connStr))
            {
                conn.Open();

                string coordsHash;

                using (var md5 = MD5.Create())
                using (var ins = new FileStream(this.FileName, FileMode.Open, FileAccess.Read))
                {
                    coordsHash = md5.ComputeHash(ins).ToHex(false);
                }

                var checkCoordsHashCmd = new SqlCommand("CheckCoordsHash", conn); ;
                checkCoordsHashCmd.CommandType = CommandType.StoredProcedure;
                checkCoordsHashCmd.Parameters.Add(new SqlParameter("CoordsHash", SqlDbType.Char, 32) { Value = coordsHash });
                int checkCoordsHashRes = (int)checkCoordsHashCmd.ExecuteScalar();

                if (checkCoordsHashRes == 0)
                {
                    string putCoordsSql = string.Format(
                        "INSERT INTO TSV (SeqName, StartTSV, EndTSV)\n\tVALUES\n {0};",
                        string.Join(
                            ",",
                            File.ReadLines(this.FileName)
                                .Select(
                                    delegate(string line)
                                    {
                                        var parts = line.Split(new char[] { ':', '-', '/', '\t' });
                                        return string.Format(
                                            "(\"{0}\", {1}, {2})",
                                            parts[0],
                                            long.Parse(parts[1]),
                                            long.Parse(parts[2])
                                            );
                                    })
                            )
                        );

                    var putCoordsCmd = new SqlCommand(putCoordsSql);
                }
            }

            return new CyNetwork(Path.GetFileNameWithoutExtension(this.FileName));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: ChristinaKarandasheva/qwerty
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                var nw = new CyNetwork("Client Network");

                var n1 = new CyNode("n1", "Node 1");
                var n2 = new CyNode("n2", "Node 2");
                nw.Nodes.Add(n1);
                nw.Nodes.Add(n2);

                var e1_2 = new CyEdge("e1", "Edge 1-2", n1, n2);
                nw.Edges.Add(e1_2);

                this.client.Networks.Add(nw);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public override CyNetwork GetNetwork(CyNetwork src)
        {
            CyNetwork res = new CyNetwork(src.Name);

            return res;
        }