private void WriteConfiguration()
        {
            //保存5条信息,默认取第一条,新登录的顶到第一条,删除最后一条,逗号分隔 1,2,3,'',''
            string[] serverNameArray    = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "ServerName", ".").Split(',');
            string[] newServerNameArray = new string[] { comboBox2.Text, "", "", "", "" };//save 5 lines
            int      newServerNameIndex = 1;

            foreach (var item in serverNameArray)
            {
                if (!newServerNameArray.Contains(item))
                {
                    newServerNameArray[newServerNameIndex] = item;
                    newServerNameIndex++;
                }
            }
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "sqlserver", "ServerName", string.Join(",", newServerNameArray));
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "sqlserver", "Authentication", comboBox3.Text);
            if (checkBox1.Checked)
            {
                string[] saLoginArray    = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "SaLogin", ".").Split(',');
                string[] newSaLoginArray = new string[] { comboBox4.Text, "", "", "", "" };//save 5 lines
                int      newsaLoginIndex = 1;
                foreach (var item in saLoginArray)
                {
                    if (!newSaLoginArray.Contains(item))
                    {
                        newSaLoginArray[newsaLoginIndex] = item;
                        newsaLoginIndex++;
                    }
                }
                IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "sqlserver", "SaLogin", string.Join(",", newSaLoginArray));
                IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "sqlserver", "SaPassword", textBox1.Text);
            }
        }
 private void WriteConfiguration()
 {
     IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "mysql", "ServerName", textBox1.Text.Trim());
     IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "mysql", "Port", textBox2.Text.Trim());
     IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "mysql", "Login", textBox3.Text.Trim());
     IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "mysql", "Password", textBox4.Text.Trim());
 }
 private void ReadConfiguration()
 {
     string[] serverNameArray = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "ServerName", ".").Split(',');
     comboBox2.Text = serverNameArray[0];
     comboBox2.Items.Clear();
     foreach (var item in serverNameArray)
     {
         if (!string.IsNullOrEmpty(item))
         {
             comboBox2.Items.Add(item);
         }
     }
     comboBox3.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "Authentication", "Windows Authentication");
     string[] saLoginArray = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "SaLogin", "sa").Split(',');
     comboBox4.Items.Clear();
     foreach (var item in saLoginArray)
     {
         if (!string.IsNullOrEmpty(item))
         {
             comboBox4.Items.Add(item);
         }
     }
     if (comboBox3.Text.Equals("SQL Server Authentication"))
     {
         comboBox4.Text = saLoginArray[0];
         textBox1.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "sqlserver", "SaPassword", "123456");
     }
 }
 private void ReadConfiguration()
 {
     textBox1.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "mysql", "ServerName", "localhost");
     textBox2.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "mysql", "Port", "3306");
     textBox3.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "mysql", "Login", "");
     textBox4.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "mysql", "Password", "");
 }
        /// <summary>
        /// constructor
        /// </summary>
        public ConfigBootStrap()
        {
            Trace.WriteLine("configuration bootstraping ...");

            JObject jobject_qx_frame_config = IO_Helper_DG.Json_GetJObjectFromJsonFile("../../config/qx_frame.config.json");//get json configuration file

            QX_Frame_Helper_DG_Config.ConnectionString_DB_QX_Frame_Default = jobject_qx_frame_config["database"]["connectionStrings"]["QX_Frame_Default"].ToString();
            QX_Frame_Helper_DG_Config.DataBaseType         = QX_Frame.Bantina.Options.Opt_DataBaseType.SqlServer;
            QX_Frame_Helper_DG_Config.Log_Location_General = jobject_qx_frame_config["log"]["Log_Location_General"].ToString();
            QX_Frame_Helper_DG_Config.Log_Location_Error   = jobject_qx_frame_config["log"]["Log_Location_Error"].ToString();
            QX_Frame_Helper_DG_Config.Log_Location_Use     = jobject_qx_frame_config["log"]["Log_Location_Use"].ToString();
            QX_Frame_Helper_DG_Config.Cache_IsCache        = jobject_qx_frame_config["cache"]["IsCache"].ToInt() == 1;
            QX_Frame_Helper_DG_Config.Cache_CacheExpirationTimeSpan_Minutes = jobject_qx_frame_config["cache"]["CacheExpirationTime_Minutes"].ToInt();
            QX_Frame_Helper_DG_Config.Cache_CacheServer = QX_Frame.Bantina.Options.Opt_CacheServer.Redis;
            QX_Frame_Helper_DG_Config.Cache_Redis_Host_ReadWrite_Array = jobject_qx_frame_config["cache"]["Cache_Redis_Host_ReadWrite_Array"].ToString().Split(',');
            QX_Frame_Helper_DG_Config.Cache_Redis_Host_OnlyRead_Array  = jobject_qx_frame_config["cache"]["Cache_Redis_Host_OnlyRead_Array"].ToString().Split(',');
            QX_Frame_Helper_DG_Config.MSMQ_RabbitMQ_Host               = jobject_qx_frame_config["rabbitmq"]["Host"].ToString();
            QX_Frame_Helper_DG_Config.MSMQ_RabbitMQ_UserName           = jobject_qx_frame_config["rabbitmq"]["UserName"].ToString();
            QX_Frame_Helper_DG_Config.MSMQ_RabbitMQ_Password           = jobject_qx_frame_config["rabbitmq"]["Password"].ToString();
            QX_Frame_Helper_DG_Config.MSMQ_RabbitMQ_VirtualHost        = jobject_qx_frame_config["rabbitmq"]["VirtualHost"].ToString();
            QX_Frame_Helper_DG_Config.MSMQ_RabbitMQ_RequestedHeartBeat = Convert.ToUInt16(jobject_qx_frame_config["rabbitmq"]["RequestedHeartBeat"]);

            QX_Frame_Helper_DG_Config.International_ConfigFileLocation = @"../../config/qx_frame.internationalization.json";
            QX_Frame_Helper_DG_Config.International_Language           = "english";


            Trace.WriteLine("configuration bootstrap succeed !");
        }
        //POST : api/Picture/id
        public async Task <IHttpActionResult> Post(string id)
        {
            string SAVE_DIR = string.IsNullOrEmpty(id) ? UPLOAD_DIR : Path.Combine(UPLOAD_DIR, id);

            //check file type
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new Exception_DG("unsupported media type", 2005);
            }
            string dir = Path.Combine(IO_Helper_DG.RootPath_MVC, "/temp");

            IO_Helper_DG.CreateDirectoryIfNotExist(dir);

            var provider = new MultipartFormDataStreamProvider(dir);

            // Read the form data.
            await Request.Content.ReadAsMultipartAsync(provider);

            List <string> fileNameList = new List <string>();

            StringBuilder sb = new StringBuilder();

            long fileTotalSize = 0;

            int fileIndex = 1;

            // This illustrates how to get the file names.
            foreach (MultipartFileData file in provider.FileData)
            {
                //new folder
                string saveDir = Path.Combine(IO_Helper_DG.RootPath_MVC, SAVE_DIR);

                IO_Helper_DG.CreateDirectoryIfNotExist(saveDir);

                if (File.Exists(file.LocalFileName))
                {
                    //get file name
                    string fileName = file.Headers.ContentDisposition.FileName.Substring(1, file.Headers.ContentDisposition.FileName.Length - 2);
                    //create new file name
                    string newFileName = String.Concat(Guid.NewGuid(), ".", fileName.Split('.')[1]);

                    string newFullFileName = Path.Combine(saveDir, newFileName);

                    fileNameList.Add(Path.Combine(SAVE_DIR, newFileName));

                    FileInfo fileInfo = new FileInfo(file.LocalFileName);

                    fileTotalSize += fileInfo.Length;

                    sb.Append($" #{fileIndex} Uploaded file: {newFileName} ({ fileInfo.Length} bytes)");

                    fileIndex++;

                    File.Move(file.LocalFileName, newFullFileName);

                    Trace.WriteLine("1 file copied , filePath=" + newFullFileName);
                }
            }
            return(OK($"{fileNameList.Count} file(s) /{fileTotalSize} bytes uploaded successfully! Details -> {sb.ToString()} -- qx_frame {DateTime_Helper_DG.Get_DateTime_Now_24HourType()}", fileNameList, fileNameList.Count));
        }
 /// <summary>
 /// Get JObject from json config file
 /// </summary>
 /// <returns></returns>
 private static JObject GetJObject()
 {
     if (string.IsNullOrEmpty(QX_Frame_Helper_DG_Config.International_ConfigFileLocation))
     {
         throw new Exception_DG("QX_Frame_Config.International_ConfigFileLocation must be provide correctly ! -- QX_Frame.Bantina.Extends.Exception_DG line:18");
     }
     return(IO_Helper_DG.Json_GetJObjectFromJsonFile(QX_Frame_Helper_DG_Config.International_ConfigFileLocation));//get json configuration file
 }
        protected static string GetERROR_XXX(int ERROR_Code)
        {
            if (string.IsNullOrEmpty(QX_Frame_Helper_DG_Config.International_ConfigFileLocation))
            {
                throw new Exception_DG("QX_Frame_Helper_DG_Config.International_ConfigFileLocation must be provide correctly ! -- QX_Frame.Bantina.Extends.Exception_DG line:18");
            }
            JObject jobject = IO_Helper_DG.Json_GetJObjectFromJsonFile(QX_Frame_Helper_DG_Config.International_ConfigFileLocation);//get json configuration file

            return(jobject[QX_Frame_Helper_DG_Config.International_Language][$"ERROR_{ERROR_Code}"].ToString());
        }
Esempio n. 9
0
        public Exception_DG_Internationalization(int errorCode) : base("Refrence Message_DG")
        {
            if (string.IsNullOrEmpty(QX_Frame_Helper_DG_Config.International_ConfigFileLocation))
            {
                throw new Exception_DG("QX_Frame_Helper_DG_Config.International_ConfigFileLocation must be provide correctly ! -- QX_Frame.Bantina.Extends.Exception_DG line:69");
            }
            JObject jobject = IO_Helper_DG.Json_GetJObjectFromJsonFile(QX_Frame_Helper_DG_Config.International_ConfigFileLocation);//get json configuration file

            this.Message_DG = jobject[QX_Frame_Helper_DG_Config.International_Language][$"ERROR_{errorCode}"].ToString();
            this.ErrorCode  = errorCode;
        }
Esempio n. 10
0
        //Export To Excel
        private void button22_Click(object sender, EventArgs e)
        {
            string filePath        = textBox6.Text.Trim();
            string fileComplexPath = $"{ filePath + DataBaseName}.xlsx";

            IO_Helper_DG.CreateDirectoryIfNotExist(filePath);
            new Thread(() =>
            {
                Office_Helper_DG.DataTableToExcel(fileComplexPath, textBox9.Text.Trim(), this.DataBaseTable);
            }).Start();
            MessageBox.Show("OutPut->" + fileComplexPath);
        }
Esempio n. 11
0
        //将文本框文件保存到桌面
        private void saveCodeToFile()
        {
            string dirPath         = textBox6.Text;
            string fileComplexPath = dirPath + textBox4.Text + comboBox1.Text;

            IO_Helper_DG.CreateDirectoryIfNotExist(dirPath);
            using (FileStream fs = new FileStream(fileComplexPath, FileMode.Create))
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.Write(CodeTxt);
                sw.Close();
            }
        }
        //POST : api/File
        public async Task <IHttpActionResult> Post()
        {
            string SAVE_DIR = UPLOAD_DIR;
            //save folder
            string root = Path.Combine(IO_Helper_DG.RootPath_MVC, SAVE_DIR);

            //check path is exist if not create it
            IO_Helper_DG.CreateDirectoryIfNotExist(root);

            IList <string> fileNameList = new List <string>();

            StringBuilder sb = new StringBuilder();

            long fileTotalSize = 0;

            int fileIndex = 1;

            //get files from request
            HttpFileCollection files = HttpContext.Current.Request.Files;

            await Task.Run(() =>
            {
                foreach (var f in files.AllKeys)
                {
                    HttpPostedFile file = files[f];
                    if (!string.IsNullOrEmpty(file.FileName))
                    {
                        string fileLocalFullName = Path.Combine(root, file.FileName);

                        file.SaveAs(fileLocalFullName);

                        fileNameList.Add(Path.Combine(SAVE_DIR, file.FileName));

                        FileInfo fileInfo = new FileInfo(fileLocalFullName);

                        fileTotalSize += fileInfo.Length;

                        sb.Append($" #{fileIndex} Uploaded file: {file.FileName} ({ fileInfo.Length} bytes)");

                        fileIndex++;

                        Trace.WriteLine("1 file copied , filePath=" + fileLocalFullName);
                    }
                }
            });

            return(OK($"{fileNameList.Count} file(s) /{fileTotalSize} bytes uploaded successfully! Details -> {sb.ToString()} -- qx_frame {DateTime_Helper_DG.Get_DateTime_Now_24HourType()}", fileNameList, fileNameList.Count));
        }
Esempio n. 13
0
        //write ini config record the opration history
        private void setInitConfigFile()
        {
            //set config
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "config", "outputType", comboBox2.Text);//output type

            //set code builder config
            //IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "usings", textBox3.Text.Replace("\n","&")); //using
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "namespace", textBox2.Text);            //namespace
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "namespaceCommonPlus", textBox10.Text); //namespace
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "TableName", textBox9.Text);            //table name
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "class", textBox5.Text);                //class name
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "ClassNamePlus", textBox7.Text);        // ClassExtends
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "ClassExtends", textBox8.Text);         // ClassExtends
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "fileName", textBox4.Text);             //fileName
            IO_Helper_DG.Ini_Update(CommonVariables.configFilePath, "code", "fileNameSuffix", comboBox1.Text);      //fileName
        }
Esempio n. 14
0
        //Generate Three-Layout-Frame
        private void button15_Click(object sender, EventArgs e)
        {
            //Generate QX_Frame.Data.Entities
            textBox2.Text = "QX_Frame.Data.Entities";
            textBox7.Text = "";
            textBox8.Text = $"Entity<{DataBaseName}, {TableName}>";
            CommonComponent(() => NetEntityWithBantina.CreateCode(CreateInfoDic));
            //Generate QX_Frame.Data.QueryObject
            textBox3.Text = "using QX_Frame.App.Base;\nusing QX_Frame.Data.Entities;\nusing System;\nusing System.Linq.Expressions;";
            textBox2.Text = "QX_Frame.Data.QueryObject";
            textBox7.Text = "QueryObject";
            textBox8.Text = $"WcfQueryObject<{DataBaseName}, {TableName}>";
            CommonComponent(() => QX_FrameToQueryObject.CreateCode(CreateInfoDic));

            //Generate QX_Frame.Data.Service
            textBox3.Text = "using QX_Frame.App.Base;\nusing QX_Frame.Data.Contract;\nusing QX_Frame.Data.Entities;";
            textBox2.Text = "QX_Frame.Data.Service";
            textBox7.Text = "Service";
            string tableNameRelace = TableName.Replace("TB_", "").Replace("tb_", "").Replace("t_", "").Replace("T_", "");

            textBox5.Text = tableNameRelace;
            textBox8.Text = $"WcfService, I{tableNameRelace}Service";
            CommonComponent(() => QX_FrameToDataService.CreateCode(CreateInfoDic));

            string dirPath         = textBox6.Text;
            string fileComplexPath = dirPath + "ClassRegister.txt";

            IO_Helper_DG.CreateDirectoryIfNotExist(dirPath);

            using (StreamWriter sw = new StreamWriter(fileComplexPath, true))
            {
                sw.WriteLine($"AppBase.Register(c => new {tableNameRelace}Service());");
                sw.Close();
            }

            //Generate QX_Frame.Data.Contract
            textBox3.Text = "using QX_Frame.Data.Entities;";
            textBox2.Text = "QX_Frame.Data.Contract";
            textBox5.Text = $"I{textBox5.Text.Replace("TB_", "").Replace("tb_", "").Replace("t_", "").Replace("T_", "")}";
            textBox7.Text = "Service";
            textBox8.Text = "";
            CommonComponent(() => QX_FrameToDataContract.CreateCode(CreateInfoDic));
        }
Esempio n. 15
0
        /// <summary>
        /// DownLoad Images
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DownLoadImages(Guid id, string title)
        {
            string dirInput      = Path.Combine(Server.MapPath("~/Uploads"), id.ToString());
            string outPutZipFile = Path.Combine(Server.MapPath("~/Uploads/OutPut"), title + ".zip");
            string OutPutZipDir  = Server.MapPath("~/Uploads/OutPut");

            if (!Directory.Exists(dirInput))
            {
                Directory.CreateDirectory(dirInput);
            }

            IO_Helper_DG.ZipDir(dirInput, outPutZipFile);

            Task_Helper_DG.TaskRun(() =>
            {
                foreach (var item in Directory.GetFiles(OutPutZipDir))
                {
                    if (!item.Equals(outPutZipFile))
                    {
                        System.IO.File.Delete(item);
                    }
                }
            });

            FileStream fileStream = new FileStream(outPutZipFile, FileMode.Open);
            long       fileSize   = fileStream.Length;

            byte[] fileBuffer = new byte[fileSize];
            fileStream.Read(fileBuffer, 0, (int)fileSize);
            //如果不写fileStream.Close()语句,用户在下载过程中选择取消,将不能再次下载
            fileStream.Close();

            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(title + ".zip", Encoding.UTF8));
            Response.AddHeader("Content-Length", fileSize.ToString());

            Response.BinaryWrite(fileBuffer);
            Response.End();
            Response.Close();

            return(OK("download success"));
        }
Esempio n. 16
0
        /// <summary>
        /// constructor
        /// </summary>
        public ConfigBootStrap()
        {
            JObject jobject_qx_frame_config = IO_Helper_DG.Json_GetJObjectFromJsonFile("../../config/qx_frame.config.json");//get json configuration file

            QX_Frame_Helper_DG_Config.ConnectionString_DB_QX_Frame_Default = jobject_qx_frame_config["database"]["connectionStrings"]["QX_Frame_Default"].ToString();
            QX_Frame_Helper_DG_Config.Log_Location_General = jobject_qx_frame_config["log"]["Log_Location_General"].ToString();
            QX_Frame_Helper_DG_Config.Log_Location_Error   = jobject_qx_frame_config["log"]["Log_Location_Error"].ToString();
            QX_Frame_Helper_DG_Config.Log_Location_Use     = jobject_qx_frame_config["log"]["Log_Location_Use"].ToString();
            QX_Frame_Helper_DG_Config.Cache_IsCache        = jobject_qx_frame_config["cache"]["IsCache"].ToInt() == 1;
            QX_Frame_Helper_DG_Config.Cache_CacheExpirationTimeSpan_Minutes = jobject_qx_frame_config["cache"]["CacheExpirationTime_Minutes"].ToInt();
            QX_Frame_Helper_DG_Config.Cache_CacheServer = QX_Frame.Bantina.Options.Opt_CacheServer.HttpRuntimeCache;
            QX_Frame_Helper_DG_Config.Cache_Redis_Host_ReadWrite_Array = jobject_qx_frame_config["cache"]["Cache_Redis_Host_ReadWrite_Array"].ToString().Split(',');
            QX_Frame_Helper_DG_Config.Cache_Redis_Host_OnlyRead_Array  = jobject_qx_frame_config["cache"]["Cache_Redis_Host_OnlyRead_Array"].ToString().Split(',');
            QX_Frame_Helper_DG_Config.International_ConfigFileLocation = @"../../config/qx_frame.internationalization.json";
            QX_Frame_Helper_DG_Config.International_Language           = "english";

            QX_Frame_Data_Config.ConnectionString_DB_QX_Frame_Test = jobject_qx_frame_config["database"]["connectionStrings"]["DB_QX_Frame_Test"].ToString();

            Trace.WriteLine("configuration bootstrap succeed !");
        }
Esempio n. 17
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // set copyright
                label_Author.Text      += Info.Author;
                label_Version.Text     += Info.VersionNum;
                label_Description.Text += Info.Description;

                //set config
                comboBox2.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "config", "outputType");//output type

                //set code builder config
                // textBox3.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "usings").Replace('&','\n'); //using
                textBox2.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "namespace");              //namespace
                textBox10.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "namespaceCommonPlus");    //namespace
                textBox9.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "TableName");              //table name
                textBox5.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "class");                  //class name
                textBox7.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "ClassNamePlus");          //ClassExtends
                textBox8.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "ClassExtends");           //ClassExtends
                textBox4.Text  = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "fileName");               //fileName
                comboBox1.Text = IO_Helper_DG.Ini_SelectStringValue(CommonVariables.configFilePath, "code", "fileNameSuffix", ".txt"); //fileNameSuffix

                textBox6.Text = dir + "\\qixiaoCodeBuilder\\";
                colorRichTextBox1.Language = CSharp_FlowchartToCode_DG.Controls.ColorRichTextBox.Languages.SQL;
                colorRichTextBox1.Language = CSharp_FlowchartToCode_DG.Controls.ColorRichTextBox.Languages.SQL;

                dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView2.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;
                dataGridView1.ColumnHeadersHeight = 22;

                timer1.Interval = 50;//progress refresh time
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }