Exemplo n.º 1
0
 //调整顺序
 public JsonResult UpdateIndex(int startIndex, int stopIndex, string GDH)
 {
     using (var db = new MySqlServer())
         try
         {
             if (HanderDataForXF_SYService.GetOne(T => T.GDH == GDH) != null)
             {
                 db.Database.GetInt(string.Format("update HanderDataForXF_SY set [index]=-1 where [index]={0} and GDH='{1}' ", stopIndex, GDH));
                 db.Database.GetInt(string.Format("update HanderDataForXF_SY set [index]={0} where [index]={1} and GDH='{2}' ", stopIndex, startIndex, GDH));
                 db.Database.GetInt(string.Format("update HanderDataForXF_SY set [index]={0} where [index]={1} and GDH='{2}' ", startIndex, -1, GDH));
                 return(Json(new { state = 1, msg = "排序成功。" }, JsonRequestBehavior.AllowGet));
             }
             else if (HanderDataForXF_KZService.GetOne(T => T.GDH == GDH) != null)
             {
                 db.Database.GetInt(string.Format("update HanderDataForXF_KZ set [index]=-1 where [index]={0} and GDH='{1}' ", stopIndex, GDH));
                 db.Database.GetInt(string.Format("update HanderDataForXF_KZ set [index]={0} where [index]={1} and GDH='{2}' ", stopIndex, startIndex, GDH));
                 db.Database.GetInt(string.Format("update HanderDataForXF_KZ set [index]={0} where [index]={1} and GDH='{2}' ", startIndex, -1, GDH));
                 return(Json(new { state = 1, msg = "排序成功。" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 throw new Exception("系统出错:数据库中找不到对应数据。");
             }
         }
         catch (Exception ex)
         {
             return(Json(new { state = 0, msg = ex.Message }, JsonRequestBehavior.AllowGet));
         }
 }
Exemplo n.º 2
0
        public SqlServerPropertiesDockForm(ref MySqlServer mySqlServer)
        {
            InitializeComponent();

            _mySqlServer = mySqlServer;

            var p = Process.GetCurrentProcess();

            privateRamCounter = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName, true);
            cpuCounter        = new PerformanceCounter("Process", "% Processor Time", p.ProcessName, true);
            ramCounter        = new PerformanceCounter("Process", "Working Set", p.ProcessName, true);

            foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_ComputerSystem").Get())
            {
                physicalCpuCount = int.Parse(item["NumberOfProcessors"].ToString());
                logicalCpuCount  = int.Parse(item["NumberOfLogicalProcessors"].ToString());
            }

            foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_Processor").Get())
            {
                coreCount += int.Parse(item["NumberOfCores"].ToString());
            }


            // Preinitialize lists
            _cpuUsageList           = new List <float>();
            _ramUsageList           = new List <float>();
            _privateMemoryUsageList = new List <float>();
            for (int i = 0; i < SAMPLE_COUNT; i++)
            {
                _cpuUsageList.Add(0);
                _ramUsageList.Add(0);
                _privateMemoryUsageList.Add(0);
            }
        }
Exemplo n.º 3
0
        MySqlServer SetupMySqlServer(ErrorResultTO errors)
        {
            var server = new MySqlServer();

            try
            {
                var connected = server.Connect(Source.ConnectionString, CommandType.StoredProcedure, ProcedureName);
                if (!connected)
                {
                    Dev2Logger.Error(string.Format(ErrorResource.FailedToConnectWithConnectionString,
                                                   Source.ConnectionString), GlobalConstants.WarewolfError);
                }
                return(server);
            }
            catch (MySqlException sex)
            {
                var errorMessages = new StringBuilder();
                errorMessages.Append(sex.Message);
                errors.AddError(errorMessages.ToString());
                Dev2Logger.Error(errorMessages.ToString(), GlobalConstants.WarewolfError);
            }
            catch (Exception ex)
            {
                errors.AddError($"{ex.Message}{Environment.NewLine}{ex.StackTrace}");
                Dev2Logger.Error(ex, GlobalConstants.WarewolfError);
            }
            return(server);
        }
Exemplo n.º 4
0
        //修改尺码表状态
        public JsonResult UpdateState(string Code, string state, string Action)
        {
            using (var db = new MySqlServer())
                try
                {
                    switch (Action)
                    {
                    case "XF_SY_NAN":

                        db.Database.GetInt(string.Format("update   XF_SY_NAN_ChiMa set status='{0}' where Size_Code='{1}'", state, Code));
                        return(Json(new { state = 1, msg = "" }, JsonRequestBehavior.AllowGet));

                    case "XF_SY_NU":
                        db.Database.GetInt(string.Format("update XF_SY_NU_ChiMa set status='{0}' where Size_Code='{1}'", state, Code));
                        return(Json(new { state = 1, msg = "" }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NAN":
                        db.Database.GetInt(string.Format("update XF_KZ_CodeSize set status='{0}' where Size_Code='{1}'", state, Code));
                        return(Json(new { state = 1, msg = "" }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NU":
                        db.Database.GetInt(string.Format("update XF_KZ_CodeSize set status='{0}' where Size_Code='{1}'", state, Code));
                        return(Json(new { state = 1, msg = "" }, JsonRequestBehavior.AllowGet));

                    default:
                        throw new Exception("系统出错:没有对应的Action");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = -1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }
Exemplo n.º 5
0
        //加载尺码表详细信息
        public JsonResult BugCodeSize(string Size_Code, string Action)
        {
            using (var db = new MySqlServer())
                try
                {
                    switch (Action)
                    {
                    case "XF_SY_NAN":

                        return(Json(new { state = 1, msg = XF_SY_NAN_ChiMa.Query(T => T.Status == 1 && T.Size_Code == Size_Code, o => o.Id, false).ToList() }, JsonRequestBehavior.AllowGet));

                    case "XF_SY_NU":

                        return(Json(new { state = 1, msg = XF_SY_NU_ChiMa.Query(T => T.Status == 1 && T.Size_Code == Size_Code, o => o.Id, false).ToList() }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NAN":
                        return(Json(new { state = 1, msg = XF_KZ_Service.Query(T => T.Status == 1 && T.Size_Code == Size_Code, o => o.Id, false).ToList() }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NU":
                        return(Json(new { state = 1, msg = XF_KZ_Service.Query(T => T.Status == 1 && T.Size_Code == Size_Code, o => o.Id, false).ToList() }, JsonRequestBehavior.AllowGet));

                    default:
                        throw new Exception("系统出错:没有对应的Action");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = -1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }
Exemplo n.º 6
0
        public JsonResult Manage(string Code, string Action)
        {
            using (var db = new MySqlServer())
                try
                {
                    switch (Action)
                    {
                    case "XF_SY_NAN":    //西服上衣  男

                        return(Json(new { state = 1, msg = XF_SY_NAN_ChiMa.Query(T => T.Size_Code == Code && T.IsDeleted == false, O => O.Id, false) }, JsonRequestBehavior.AllowGet));

                    case "XF_SY_NU":
                        return(Json(new { state = 1, msg = XF_SY_NU_ChiMa.Query(T => T.Size_Code == Code && T.IsDeleted == false, O => O.Id, false) }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NAN":
                    case "XF_KZ_NU":

                        return(Json(new { state = 1, msg = XF_KZ_CodeSizeService.Query(T => T.Size_Code == Code && T.IsDeleted == false, O => O.Id, false), HeightKuChang = HeightKuChangService.Query(T => T.Size_Code == Code && T.IsDeleted == false, O => O.Id, false) }, JsonRequestBehavior.AllowGet));

                    default:
                        throw new Exception("系统出错:没有对应的Action");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = 1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }
Exemplo n.º 7
0
        //尺码表编号下拉
        public JsonResult SizeCodeSelect(string Action)
        {
            using (var db = new MySqlServer())
                try
                {
                    switch (Action)
                    {
                    case "XF_SY_NAN":    //西服上衣  男

                        List <XF_SY_NAN_ChiMaDto> XF_SY_NAN = db.Database.GetList <XF_SY_NAN_ChiMaDto>("select Size_Code from XF_SY_NAN_ChiMa where Status=0 Group By Size_Code");
                        return(Json(new { state = 1, msg = XF_SY_NAN }, JsonRequestBehavior.AllowGet));

                    case "XF_SY_NU":
                        List <XF_SY_NU_CodeSizeDto> XF_SY_NU = db.Database.GetList <XF_SY_NU_CodeSizeDto>("select Size_Code from XF_SY_NU_CodeSize where Status=0 Group By Size_Code");


                        return(Json(new { state = 1, msg = XF_SY_NU }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NAN":    //西服裤子
                    case "XF_KZ_NU":

                        List <XF_KZ_CodeSizeDto> XF_KZ = db.Database.GetList <XF_KZ_CodeSizeDto>("select Size_Code from XF_KZ_CodeSize where Status=0 Group By Size_Code");

                        return(Json(new { state = 1, msg = XF_KZ }, JsonRequestBehavior.AllowGet));

                    default:
                        throw new Exception("系统出错:没有对应的Action");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = -1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }
Exemplo n.º 8
0
        private bool MySqlExecution(ErrorResultTO errors)
        {
            try
            {
                List <MySqlParameter> parameters = GetMySqlParameters(Service.Method.Parameters);

                using (
                    MySqlServer server = SetupMySqlServer(errors))
                {
                    if (parameters != null)
                    {
                        // ReSharper disable CoVariantArrayConversion
                        using (DataTable dataSet = server.FetchDataTable(parameters.ToArray(), server.GetProcedureOutParams(Service.Method.Name, Source.DatabaseName)))
                        // ReSharper restore CoVariantArrayConversion
                        {
                            ApplyColumnMappings(dataSet);
                            TranslateDataTableToEnvironment(dataSet, DataObj.Environment);
                            return(true);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                errors.AddError(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace));
            }
            return(false);
        }
Exemplo n.º 9
0
        //验证西服上衣格式(女)
        public static bool Verification_XF_SY_NU(DataTable table)
        {
            using (var db = new MySqlServer())
                try
                {
                    var vc = db.Database.GetString(@"  select  D_Value  from Dictionaries where d_Key='ExcelColumnsCount_XF_SY_NU'   ");

                    int count = 0;

                    if (!int.TryParse(vc, out count))
                    {
                        throw new Exception("系统出错,没有配置excel验证条件。");
                    }

                    if (table.Columns.Count != count)
                    {
                        throw new Exception("Excel格式出错,请检查文件");
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    throw;
                }
        }
Exemplo n.º 10
0
        public void ExampleTest()
        {
            //Setting up and starting the server
            //This can also be done in a AssemblyInitialize method to speed up tests
            MySqlServer dbServer = MySqlServer.Instance;

            dbServer.StartServer();

            //Create a database and select it
            MySqlHelper.ExecuteNonQuery(dbServer.GetConnectionString(), string.Format("CREATE DATABASE {0};USE {0};", _testDatabaseName));

            //Create a table
            MySqlHelper.ExecuteNonQuery(dbServer.GetConnectionString(_testDatabaseName), "CREATE TABLE testTable (`id` INT NOT NULL, `value` CHAR(150) NULL,  PRIMARY KEY (`id`)) ENGINE = MEMORY;");

            //Insert data (large chunks of data can of course be loaded from a file)
            MySqlHelper.ExecuteNonQuery(dbServer.GetConnectionString(_testDatabaseName), "INSERT INTO testTable (`id`,`value`) VALUES (1, 'some value')");
            MySqlHelper.ExecuteNonQuery(dbServer.GetConnectionString(_testDatabaseName), "INSERT INTO testTable (`id`, `value`) VALUES (2, 'test value')");

            //Load data
            using (MySqlDataReader reader = MySqlHelper.ExecuteReader(dbServer.GetConnectionString(_testDatabaseName), "select * from testTable WHERE id = 2"))
            {
                reader.Read();

                Assert.AreEqual("test value", reader.GetString("value"), "Inserted and read string should match");
            }

            //Shutdown server
            dbServer.ShutDown();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.WriteLine("connecting to database");
            var svr = MySqlServer.GetMySqlServer("test.water.usbr.gov", "timeseries", "");
            TimeSeriesDatabase db = new TimeSeriesDatabase(svr);

            Console.WriteLine("reading sitecatalog");
            var sites = db.GetSiteCatalog();

            var sc = db.GetSeriesCatalog("isfolder=0");

            var prop = db.GetSeriesProperties(true);

            for (int i = 0; i < sc.Count; i++)
            {
                var s   = db.GetSeries(sc[i].id);
                var por = s.GetPeriodOfRecord();

                if (por.Count > 0)
                {
                    s.Properties.Set("t1", por.T1.ToString("yyyy-MM-dd"));
                    s.Properties.Set("t2", por.T2.ToString("yyyy-MM-dd"));
                    Console.WriteLine(s.Name);
                }
            }

            db.Server.SaveTable(prop);

            //SetRegioninSiteTable(db, sites);
            // UpdateGPSiteInfo(sites);

            svr.SaveTable(sites);

            Console.WriteLine();
        }
Exemplo n.º 12
0
 //导出裁单
 public JsonResult LoadOrder(string Action, string GDH)
 {
     using (var db = new MySqlServer())
         try
         {
             if (HanderDataForXF_SYService.GetOne(T => T.GDH == GDH) != null)
             {
                 var orderlist = db.Database.GetList <DictionariesDto>("select * from Dictionaries where D_Key='HanderDataForXF_SYOrder'");
                 return(Json(new { state = 1, msg = orderlist }, JsonRequestBehavior.DenyGet));
             }
             else
             {
                 var orderlist = db.Database.GetList <DictionariesDto>("select * from Dictionaries where D_Key='HanderDataForXF_KZOrder'");
                 return(Json(new { state = 1, msg = orderlist }, JsonRequestBehavior.DenyGet));
             }
         }
         catch (Exception ex)
         {
             return(Json(new
             {
                 state = 0,
                 msg = ex.Message
             }, JsonRequestBehavior.AllowGet));
         }
 }
Exemplo n.º 13
0
        private MySqlServer SetupMySqlServer(ErrorResultTO errors)
        {
            var server = new MySqlServer();

            try
            {
                bool connected = server.Connect(Source.ConnectionString, CommandType.StoredProcedure,
                                                String.IsNullOrEmpty(Service.Method.ExecuteAction)
                        ? Service.Method.Name
                        : Service.Method.ExecuteAction);
                if (!connected)
                {
                    Dev2Logger.Log.Error(string.Format("Failed to connect with the following connection string: '{0}'",
                                                       Source.ConnectionString));
                }
                return(server);
            }
            catch (MySqlException sex)
            {
                // 2013.06.24 - TWR - added errors logging
                var errorMessages = new StringBuilder();
                errorMessages.Append(sex.Message);
                errors.AddError(errorMessages.ToString());
                Dev2Logger.Log.Error(errorMessages.ToString());
            }
            catch (Exception ex)
            {
                // 2013.06.24 - TWR - added errors logging
                errors.AddError(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace));
                Dev2Logger.Log.Error(ex);
            }
            return(server);
        }
Exemplo n.º 14
0
 public void OpenNoPropertiesTest()
 {
     // Test the MySQL server connection
     using (MySqlServer target = new MySqlServer())
     {
         target.Open();
     }
 }
Exemplo n.º 15
0
        public void TestMySQL()
        {
            var svr = MySqlServer.GetMySqlServer("localhost", "timeseries");

            var db = new TimeSeriesDatabase(svr, false);

            BasicDatabaseTest(db);
        }
Exemplo n.º 16
0
        public void StartServerOnSpecifiedPort()
        {
            MySqlServer server = MySqlServer.Instance;

            server.StartServer(3366);
            MySqlHelper.ExecuteNonQuery(server.GetConnectionString(), "CREATE DATABASE testserver; USE testserver;");
            server.ShutDown();
        }
Exemplo n.º 17
0
        public DataPreviewDockForm(ref MySqlServer mySqlServer)
        {
            InitializeComponent();

            _mySqlServer = mySqlServer;

            this.richTextBox1.Text = AppSettings.Default.NoObjectSelectedDefaultText;
            this.Enabled           = false;
        }
Exemplo n.º 18
0
        public void KillProcess()
        {
            int previousProcessCount = Process.GetProcessesByName("mysqld").Length;

            MySqlServer database = MySqlServer.Instance;

            database.StartServer();
            database.ShutDown();

            Assert.AreEqual(previousProcessCount, Process.GetProcessesByName("mysqld").Length, "should kill the running process");
        }
Exemplo n.º 19
0
        public ObjectDefinitionDockForm(ref MySqlServer mySqlServer)
        {
            InitializeComponent();

            _mySqlServer = mySqlServer;

            this.richTextBoxObjectName.Text = AppSettings.Default.NoObjectSelectedDefaultText;
            this.Enabled = false;

            _defaultSelectionColor = richTextBoxObjectDef.SelectionColor;
            _defaultSelectionFont  = richTextBoxObjectDef.Font;
        }
Exemplo n.º 20
0
 //加载列表
 public JsonResult GetList(string GDH)
 {
     using (var db = new MySqlServer())
         try
         {
             return(Json(new { state = 1, msg = db.Database.GetList <DCL_DataDto>(string.Format("select * from DCL_Data where GDH='{0}'", GDH)) }, JsonRequestBehavior.AllowGet));
         }
         catch (Exception ex)
         {
             return(Json(new { state = 1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
         }
 }
Exemplo n.º 21
0
        public BackupMySql(string server, int port, string user, string password, string database, string pasta)
        {
            VariaveisGeral.NomeAssembly = GetType().Name;

            //1) Primeiro a ser inicializado devido do IoC
            InicializarBootstrapper();

            //2) Segundo a ser inicializado devido aos dados do Banco de dados
            InicializarConnectionString(server, port, user, password, database);

            InicializarPastas(pasta);

            MySqlDatabase = VariaveisGeral.Container.GetInstance <MySqlDatabase>();

            MySqlServer = VariaveisGeral.Container.GetInstance <MySqlServer>();
        }
Exemplo n.º 22
0
 /// <summary>
 /// Main entry form
 /// </summary>
 /// <param name="args"></param>
 public static void startRwisUiMain(string[] args)
 {
     if (jrDebug)
     {
         // Connect to DB Server
         string        dbname = ConfigurationManager.AppSettings["MySqlDatabase"];
         string        server = ConfigurationManager.AppSettings["MySqlServer"];
         string        user   = ConfigurationManager.AppSettings["MySqlUser"];
         BasicDBServer svr    = MySqlServer.GetMySqlServer(server, dbname, user);
         db      = new TimeSeriesDatabase(svr);
         siteCat = db.GetSiteCatalog();
         parCat  = db.GetParameterCatalog();
     }
     // Starts the application.
     Application.Run(new rwisForm());
 }
Exemplo n.º 23
0
        public static TimeSeriesDatabase InitDatabase(Arguments args, bool readOnly = false)
        {
            if (args.Contains("database"))
            {
                if (File.Exists(args["database"]))
                {
                    SQLiteServer svr = new SQLiteServer(args["database"]);
                    var          db  = new TimeSeriesDatabase(svr, LookupOption.TableName, readOnly);
                    return(db);
                }

                int idx = args["database"].IndexOf(":");
                if (idx > 0)
                {// postgresql
                }
                throw new NotImplementedException("Please use app.config file");
            }
            else if (ConfigurationManager.AppSettings["PostgresDatabase"] != null)
            {// use config file (postgresql is default)
                Logger.WriteLine("using postgresql");
                var dbname = ConfigurationManager.AppSettings["PostgresDatabase"];
                var svr    = PostgreSQL.GetPostgresServer(dbname);
                var db     = new TimeSeriesDatabase(svr, LookupOption.TableName, readOnly);
                db.Parser.RecursiveCalculations = false;
                Logger.WriteLine("database initilized..");
                return(db);
            }
            else if (ConfigurationManager.AppSettings["MySqlDatabase"] != null)
            {// use config file (postgresql is default)
                Logger.WriteLine("using mysql");
                var    dbname = ConfigurationManager.AppSettings["MySqlDatabase"];
                var    server = ConfigurationManager.AppSettings["MySqlServer"];
                var    user   = ConfigurationManager.AppSettings["MySqlUser"];
                string pass   = "";
                if (ConfigurationManager.AppSettings["MySqlPassword"] != null)
                {
                    pass = ConfigurationManager.AppSettings["MySqlPassword"];
                }
                var svr = MySqlServer.GetMySqlServer(server, dbname, user, pass);
                var db  = new TimeSeriesDatabase(svr, LookupOption.TableName, readOnly);
                db.Parser.RecursiveCalculations = false;
                Logger.WriteLine("database initilized..");
                return(db);
            }

            throw new NotImplementedException("Please use app.config file to configure database");
        }
Exemplo n.º 24
0
        public void ConnectToServer(string server, string database, DatabaseType t)
        {
            string        cs  = ""; // connection string
            BasicDBServer svr = null;

            if (t == DatabaseType.PostgreSql)
            {
                cs  = PostgreSQL.CreateADConnectionString(server, database);
                svr = new PostgreSQL(cs);
            }
            if (t == DatabaseType.SqlServer)
            {
                svr = new SqlServer(server, database);
            }
            if (t == DatabaseType.MySQL)
            {
                svr = MySqlServer.GetMySqlServer(server, database);
            }

            Connect(svr);
        }
        // =========================================

        public DatabaseBrowserDockForm(ref MySqlServer mySqlServer)
        {
            _mySqlServer = mySqlServer;

            int normalIdx = 0;
            int linkedIdx = 100000;

            InitializeComponent();

            objectListView1.Groups.Clear();

            olvColumnDatabaseName.GroupKeyGetter = delegate(object x)
            {
                return(((MySqlDatabase)x).ServerObjectName);
            };

            olvColumnDatabaseName.GroupFormatter = delegate(OLVGroup group, GroupingParameters parms)
            {
                var svr = _mySqlServer.SqlServerObjects.First(x => x.ServerObjectName.Equals(group.Key.ToString(), StringComparison.InvariantCultureIgnoreCase));
                if (!svr.IsValid)
                {
                    group.TitleImage = 2;
                }
                else
                {
                    group.TitleImage = (svr.IsLinked) ? 1 : 0;
                }

                group.Subtitle = string.Format("{0} {1}{2}", svr.ProductVersionName, svr.ProductLevel, ((svr.IsLinked) ? " (Linked)" : string.Empty));
                group.Task     = "Server Properties";

                @group.SortValue = svr.IsLinked ? linkedIdx++ : normalIdx++;
            };

            olvColumnDatabaseName.ImageGetter = delegate(object x)
            {
                return(((MySqlDatabase)x).Image);
            };
        }
Exemplo n.º 26
0
        private BasicDBServer GetServer(string server, string database, DatabaseType t, string password = "", string user = "")
        {
            BasicDBServer svr = null;

            if (user == "")
            {
                user = Environment.UserName.ToLower();
            }
            if (t == DatabaseType.PostgreSql)
            {
                svr = PostgreSQL.GetPostgresServer(database, server, user, password);
            }
            if (t == DatabaseType.SqlServer)
            {
                svr = new SqlServer(server, database);
            }
            if (t == DatabaseType.MySQL)
            {
                svr = MySqlServer.GetMySqlServer(server, database, "", password);
            }

            return(svr);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            Console.WriteLine("connecting to database");
            var svr = MySqlServer.GetMySqlServer("140.215.104.92", "timeseries", "");
            TimeSeriesDatabase db = new TimeSeriesDatabase(svr);

            Console.WriteLine("reading site catalog");
            var sites = db.GetSiteCatalog();

            sites.AddsitecatalogRow("schwind", "Schwind", "CA",
                                    "39.34752", "-121.80084", "", "", "", "", "", 0, "", "", "", "", "", "");
            sites.AddsitecatalogRow("cassidy", "Cassidy", "CA",
                                    "39.33243", "-121.78971", "", "", "", "", "", 0, "", "", "", "", "", "");
            sites.AddsitecatalogRow("risingriver", "Rising River", "CA",
                                    "39.33097", "-121.76636", "", "", "", "", "", 0, "", "", "", "", "", "");

            svr.SaveTable(sites);


            Console.WriteLine("reading series catalog");
            var series = db.GetSeriesCatalog();

            int grayLodge = series.GetOrCreateFolder("water.usbr.gov", "MP", "Gray Lodge");

            string fn = @"U:\water.usbr.gov\2016\GrayLodgeData.xlsx";

            var s = new ExcelDataReaderSeries(fn, "Rising River", "A", "B", "cfs");

            s.Name            = "Flow";
            s.Table.TableName = "mpgraylodge_instant_rising_" + s.Name;;
            s.Read();
            // db.AddSeries()

            svr.SaveTable(series);

            Console.WriteLine();
        }
Exemplo n.º 28
0
        //public void SetInMemoryDatabase(ref InMemoryDatabase inMemoryDatabase)
        //{
        //    this._inMemoryDatabase = inMemoryDatabase;

        //    textBox2.Text = string.Join(", ", inMemoryDatabase.LoadedDatabases.Select(d => "[" + d.DatabaseName + "]"));
        //}

        //public DependencyBrowserDockForm(string title, bool isTopDown)
        public DependencyBrowserDockForm(ref MySqlServer mySqlServer, string title, string[] objectTypes, bool isTopDown, int windowId)
        {
            InitializeComponent();

            this._mySqlServer = mySqlServer;

            //_objectDepParentDictionary = new Dictionary<MySqlObjectParentKey, MySqlObject>();
            //_objectDepChildDictionary = new Dictionary<MySqlObjectChildKey, MySqlObject>();
            _dependencyObjectList = new List <MySqlObject>();
            _recommendedDatabases = new List <KeyValuePair <MySqlObject, MySqlDatabase> >();

            this.Text = string.Format("New Dependency {0}", windowId);

            this.treeListView1.CanExpandGetter = delegate(object x)
            {
                return(_dependencyObjectList.Any(m => m.SystemParentId == ((MySqlObject)x).SystemId));
            };

            this.treeListView1.ChildrenGetter = delegate(object x)
            {
                return(_dependencyObjectList.Where(m => m.SystemParentId == ((MySqlObject)x).SystemId).OrderBy(m => m.ObjectName));
            };

            olvColumnObjectName.ImageGetter = delegate(object x)
            {
                return(((MySqlObject)x).Image);
            };

            treeListView1.UseAlternatingBackColors = UserSettings.Default.UseAlternatingBackColors;

            //
            //pictureBox1.too
            pictureBox1.Image = (isTopDown) ? Resources._112_DownArrowLong_Blue_32x32_72 : Resources._112_UpArrowLong_Orange_32x42_72;
            textBox1.Text     = (isTopDown) ? string.Format("Objects on which '{0}' depends on", title) : string.Format("Objects that depend on '{0}'", title);
            textBox2.Text     = string.Join(", ", _mySqlServer.SqlLoadedDatabases.Select(d => "[" + d.DatabaseName + "]"));
        }
Exemplo n.º 29
0
        internal void ExportHeaderDatabase()
        {
            var iqueryexpress = new QueryExpress();
            var mySqlServer   = new MySqlServer(iqueryexpress);


            ExportWriteComment(string.Format("Dump Begin : {0}", DateTime.Now.ToString(VariaveisGeral.FormatoData)));

            ExportWriteComment("--------------------------------------");

            ExportWriteComment(string.Format(" Backup Gerado por : {0}", VariaveisGeral.NomeAssembly));
            ExportWriteComment(string.Format(" Database:  {0}", VariaveisGeral.Database));


            ExportWriteComment(string.Format(" VersionNumber:  {0}", mySqlServer.VersionNumber));
            ExportWriteComment(string.Format(" Edition:  {0}", mySqlServer.Edition));
            ExportWriteComment(string.Format(" MajorVersionNumber:  {0}", mySqlServer.MajorVersionNumber));
            //  ExportWriteComment(string.Format(" CurrentUser:  {0}", mySqlServer.CurrentUser));


            ExportWriteComment("--------------------------------------");

            ExportWriteLine();
        }
Exemplo n.º 30
0
        //获取初排数据
        public JsonResult GetListForHanderData(string GDH, string Order, string type)
        {
            using (var db = new MySqlServer())
                try
                {
                    Order = Order.TrimEnd(',');

                    if (HanderDataForXF_SYService.GetOne(T => T.GDH == GDH) != null)
                    {
                        string xxxxdsadsax = string.Format("select ROW_NUMBER()over(order by {0}) rownum,* from (select * from  HanderDataForXF_SY ) as list order by {0}", Order);

                        //list.Height,list.Sleeve,list.Bust
                        var SYList = db.Database.GetDataTable(string.Format("select ROW_NUMBER()over(order by {0}) rownum,* from (select * from  HanderDataForXF_SY ) as list order by {0}", Order));
                        if (type != "NotOrder")
                        {
                            for (int i = 0; i < SYList.Rows.Count; i++)
                            {
                                var xxxxx = db.Database.GetInt(string.Format("update HanderDataForXF_SY set [index]={0} where id={1}", SYList.Rows[i]["rownum"].ToString(), SYList.Rows[i]["Id"].ToString()));
                            }
                        }
                        return(Json(new { state = 1, action = "HanderDataForXF_SY", msg = HanderDataForXF_SYService.Query(T => T.GDH == GDH, O => O.Index, false) }, JsonRequestBehavior.AllowGet));
                    }
                    else if (HanderDataForXF_KZService.GetOne(T => T.GDH == GDH) != null)
                    {
                        return(Json(new { state = 1, action = "HanderDataForXF_KZ", msg = HanderDataForXF_KZService.Query(T => T.GDH == GDH, O => O.Index, false) }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        throw new Exception("系统出错:数据库中找不到对应数据。");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = 0, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }