Example #1
0
        /// <summary>
        /// extract table schema
        /// </summary>
        /// <param name="model">Contain Connection string and output file</param>
        /// <returns>can be successful it is true</returns>
        public bool ExtractSchema(CompareType compare)
        {
            try
            {
                // Create Table Model
                if (AllTables.Rows.Count > 0)
                {
                    Database.Tables = new List <Table>();
                }

                foreach (var tableSchema in AllTables.Rows.Cast <DataRow>())
                {
                    var schemaTable = tableSchema["TABLE_SCHEMA"].ToString();
                    var tableName   = tableSchema["TABLE_NAME"].ToString();
                    Console.WriteLine(schemaTable + @"." + tableName);
                    var tableId = ObjectMapped
                                  .Where(x => x.schemaName.Equals(schemaTable, StringComparison.OrdinalIgnoreCase) && x.name.Equals(tableName, StringComparison.OrdinalIgnoreCase))
                                  .Select(x => x.object_id)
                                  .FirstOrDefault();


                    var newTable = new Table {
                        Name    = tableName,
                        Schema  = schemaTable,
                        Columns = FetchCulomns(tableName, schemaTable)
                    };



                    if (compare == CompareType.Schema)
                    {
                        newTable.Indexes     = FetchIndexes(tableId);
                        newTable.PrimaryKey  = FetchPrimary(tableId);
                        newTable.ForeignKeys = ReferencesMapped.Where(x =>
                                                                      x.TABLE_SCHEMA == schemaTable && x.TABLE_NAME == tableName).ToList();
                    }
                    if (compare == CompareType.Data)
                    {
                        CheckReferenceData(tableId, newTable.Name, newTable.Schema, newTable.Columns);
                    }

                    Database.Tables.Add(newTable);
                }

                Database.Tables = Database.Tables?.OrderBy(x => x.FullName).ToList();

                // Create Serialize Object and save as XML file
                Doc.Add(RootDatabase);
                AddDataToTableAndSaveFile(Database, Doc, Model.OutputFile, compare);
            } catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ForegroundColor = ConsoleColor.White;
                throw ex;
            }

            return(true);
        }
Example #2
0
    protected void Bt_upload_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            string oldname  = FileUpload1.FileName;
            string type     = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1);        //获取上传文件的后缀
            string filename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + "." + type;

            if (type == "doc")
            {
                if (FileUpload1.FileName != "")
                {
                    //更改上传文件名

                    String path = Server.MapPath("~/upfiles/" + filename);
                    FileUpload1.PostedFile.SaveAs(path);
                }


                string author = Request.Cookies["userID"].Value.ToString();
                string state  = "0";

                Hashtable docHt = new Hashtable();
                docHt.Add("docTime", SQLString.GetQuotedString(DateTime.Now.ToString()));
                docHt.Add("docTitle", SQLString.GetQuotedString(Session["docTitle"].ToString()));
                docHt.Add("docTitleEn", SQLString.GetQuotedString(Session["docTitleEn"].ToString()));
                docHt.Add("docAbstract", SQLString.GetQuotedString(Session["docAbstract"].ToString()));
                docHt.Add("docAbstractEn", SQLString.GetQuotedString(Session["docAbstractEn"].ToString()));
                docHt.Add("docKeywords", SQLString.GetQuotedString(Session["docKeywords"].ToString()));
                docHt.Add("docKeywordsEn", SQLString.GetQuotedString(Session["docKeywordsEn"].ToString()));
                docHt.Add("docLetters", SQLString.GetQuotedString(Session["docLetters"].ToString()));
                docHt.Add("docAuthor", SQLString.GetQuotedString(Session["docAuthor"].ToString()));
                docHt.Add("docColumnID", SQLString.GetQuotedString(Session["docColumnID"].ToString()));
                docHt.Add("authorID", SQLString.GetQuotedString(author));
                docHt.Add("docState", SQLString.GetQuotedString(state));

                Doc dc = new Doc();
                dc.Add(docHt);
                int docID = dc.GetID(author);

                Hashtable ht = new Hashtable();
                ht.Add("attachFilename", SQLString.GetQuotedString(oldname));
                ht.Add("attachName", SQLString.GetQuotedString(filename));
                ht.Add("docID", SQLString.GetQuotedString(Convert.ToString(docID)));
                Attach attach = new Attach();
                attach.Add(ht);


                Response.Write("<script language='javascript'>alert('投稿成功,谢谢您对本刊的支持!')</script>");
                Response.Write("<script>window.location='contribution1.aspx';</script>");
            }
            else
            {
                Response.Write("<script language='javascript'>alert('对不起,目前只接受.doc格式文档,请重新上传!')</script>");
            }
        }
    }
Example #3
0
 private void AddField(BsonElement element)
 {
     if (Doc.Contains(element.Name))
     {
         Doc.Remove(element.Name);
     }
     Doc.Add(element);
     RaisePropertyChangedNoSave("Document");
 }
 public Doc ReadDoc()
 {
     var doc = new Doc();
       ReadInt32(); //size (ignored)
       while(true)
       {
     var type = (BsonType)ReadByte();
     if (type == BsonType.EOO)
     {
       return doc;
     }
     var name = ReadShortString();
     object o = null;
     switch (type)
     {
       case BsonType.NUMBER:
     o = ReadDouble();
     break;
       case BsonType.STRING:
     o = ReadString(ReadInt32());
     break;
       case BsonType.OBJECT:
     o = ReadDoc();
     break;
       case BsonType.ARRAY:
     o = ReadDoc().ToList();
     break;
       case BsonType.BINARY:
     var count = ReadInt32();
     ReadByte(); //TODO: handle 'subtype'
     o = ReadBytes(count);
     break;
       case BsonType.UNDEFINED:
     break;
       case BsonType.OID:
     o = ReadObjectId();
     break;
       case BsonType.BOOLEAN:
     o = ReadBoolean();
     break;
       case BsonType.DATE:
     o = ReadDate();
     break;
       case BsonType.NULL:
     break;
       case BsonType.REGEX:
     o = new Regex(ReadShortString());
     ReadShortString(); //TODO: options
     break;
       case BsonType.REF:
     o = ReadDBRef();
     break;
       case BsonType.CODE:
     o = new Code(ReadString(ReadInt32()));
     break;
       case BsonType.SYMBOL:
     o = new Symbol(ReadString(ReadInt32()));
     break;
       case BsonType.CODE_W_SCOPE:
     ReadInt32();
     o = new ScopedCode(ReadString(ReadInt32()), ReadDoc());
     break;
       case BsonType.NUMBER_INT:
     o = ReadInt32();
     break;
       case BsonType.TIMESTAMP:
     o = new TimeStamp(ReadInt64());
     break;
       case BsonType.NUMBER_LONG:
     o = ReadInt64();
     break;
       case BsonType.MINKEY:
     break;
       case BsonType.MAXKEY:
     break;
       default:
     break;
     }
     doc.Add(name, o);
       }
 }
Example #5
0
        public bool Export(List <OverdueModel> overdues)
        {
            try
            {
                //清空导出文件夹
                DirectoryInfo    dir      = new DirectoryInfo(GlobalVariables.OverduePDFExportPath);
                FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
                foreach (FileSystemInfo i in fileinfo)
                {
                    if (i is DirectoryInfo)            //判断是否文件夹
                    {
                        DirectoryInfo subdir = new DirectoryInfo(i.FullName);
                        subdir.Delete(true);          //删除子目录和文件
                    }
                    else
                    {
                        File.Delete(i.FullName);      //删除指定文件
                    }
                }

                string exportFile = GlobalVariables.OverduePDFExportPath + "催费提醒_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf";
                PdfWriter.GetInstance(Doc, new FileStream(exportFile, FileMode.Create));
                Doc.Open();

                PdfPTable table = new PdfPTable(TotalCols);
                AddTitle("缴费提醒", table);
                AddSubTitle(string.Format("({0})", DateTime.Now.ToString("yyyy.MM.dd")), table);
                AddBlank(Font_Title, table);


                PdfPCell cell_nameHeader  = CreateCellWithBottomBorder("姓名", Font_TableHeader, 2);
                PdfPCell cell_classHeader = CreateCellWithBottomBorder("班级", Font_TableHeader, 4);
                PdfPCell cell_dateHeader  = CreateCellWithBottomBorder("到期日期", Font_TableHeader, 3);
                PdfPCell cell_moneyHeader = CreateCellWithBottomBorder("续缴金额", Font_TableHeader, 2);

                table.AddCell(cell_nameHeader);
                table.AddCell(cell_classHeader);
                table.AddCell(cell_dateHeader);
                table.AddCell(cell_moneyHeader);

                foreach (OverdueModel itemn in overdues)
                {
                    PdfPCell cell_regularName  = CreateCellWithNoBorder(itemn.TraineeName, Font_TableCell, 2);
                    PdfPCell cell_regularClass = CreateCellWithNoBorder(itemn.ClassName, Font_TableCell, 4);
                    PdfPCell cell_regularDate  = CreateCellWithNoBorder(itemn.OverdueDate.ToString("yyyy年MM月dd日"), Font_TableCell, 3);
                    PdfPCell cell_regularMoney = CreateCellWithNoBorder(itemn.RenewAmount.ToString(), Font_TableCell, 2);

                    table.AddCell(cell_regularName);
                    table.AddCell(cell_regularClass);
                    table.AddCell(cell_regularDate);
                    table.AddCell(cell_regularMoney);
                }

                Doc.Add(table);
                Doc.Close();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }