コード例 #1
0
        public bool Write(Dictionary<Guid,string> source, Adam.Core.Application app)
        {
            Record r = new Record(app);
            Excel.Application EApp;
            Excel.Workbook EWorkbook;
            Excel.Worksheet EWorksheet;
            Excel.Range Rng;
            EApp = new Excel.Application();
            object misValue = System.Reflection.Missing.Value;
            EWorkbook = EApp.Workbooks.Add(misValue);
            EWorksheet = (Excel.Worksheet)EWorkbook.Worksheets.Item[1];                         
            EWorksheet.get_Range("A1", misValue).Formula = "UPC code";
            EWorksheet.get_Range("B1", misValue).Formula = "Link";            
            Rng = EWorksheet.get_Range("A2", misValue).get_Resize(source.Count,misValue);
            Rng.NumberFormat = "00000000000000";
            int row = 2;
            foreach(KeyValuePair<Guid,string> pair in source)
            {              
                EWorksheet.Cells[row,1] = pair.Value;                
                r.Load(pair.Key);
                Rng = EWorksheet.get_Range("B"+row, misValue);
                EWorksheet.Hyperlinks.Add(Rng, r.Fields.GetField<TextField>("Content Url").Value);               
                //myExcelWorksheet.Cells[row, 2] = r.Fields.GetField<TextField>("Content Url").Value;                                
                row++;
            }
            ((Excel.Range)EWorksheet.Cells[2, 1]).EntireColumn.AutoFit();
            ((Excel.Range)EWorksheet.Cells[2, 2]).EntireColumn.AutoFit();
            EWorkbook.SaveAs(_fileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
                Excel.XlSaveAsAccessMode.xlExclusive,
                misValue, misValue, misValue, misValue, misValue);

            EWorkbook.Close(true, misValue, misValue);
            EApp.Quit();
            return true;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: IgorDemidov/Coubus.UI.3
        static void Main(string[] args)
        {
            Application app = new Application();
            LogOnStatus status = app.LogOn("TRAINING", "Demidov", "123456");
            Console.WriteLine(status);
            if (status != LogOnStatus.LoggedOn)
            {
                throw new UnauthorizedAccessException();
            }

            Record rec = new Record(app);
            Guid recId;
            Guid.TryParse("46e678e9-24af-4364-8926-a54600dcf188", out recId);
            rec.Load(recId);
            string s = rec.Files.LatestMaster.Path;
            Console.WriteLine(s);
            Console.ReadLine();
        }
コード例 #3
0
    public void Load(string rootpath)
    {
        string dir = ProgressContainer.ProgressDirectory(rootpath);

        Directory.CreateDirectory(dir);
        string fullpath = ProgressContainer.FullPath(rootpath, m_Id);

        if (File.Exists(fullpath))
        {
            using (BinaryReader file = new BinaryReader(File.Open(fullpath, FileMode.Open)))
            {
                int version = file.ReadInt32();
                if (version >= 1)
                {
                    int booknum = file.ReadInt32();
                    for (int i = 0; i < booknum; i++)
                    {
                        string book = file.ReadString();
                        if (!m_books.Exists(x => x == book))
                        {
                            m_books.Add(book);
                        }
                    }
                }
                int count = file.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Record record = new Record();
                    record.Load(file, version);
                    record.ProcessRecord(new Record.ProcessRecordEntry(CountOneEntry));
                    m_wordSet.Add(record.m_word, record);
                }
            }
        }

        foreach (string book in m_books)
        {
            BookDict dict = new BookDict(rootpath, book);
            dict.ReadBook(this);
            dict.SaveBook();
        }
        ReOrganize();
    }
コード例 #4
0
        public bool Write(Dictionary <Guid, string> source, Adam.Core.Application app)
        {
            Record r = new Record(app);

            Excel.Application EApp;
            Excel.Workbook    EWorkbook;
            Excel.Worksheet   EWorksheet;
            Excel.Range       Rng;
            EApp = new Excel.Application();
            object misValue = System.Reflection.Missing.Value;

            EWorkbook  = EApp.Workbooks.Add(misValue);
            EWorksheet = (Excel.Worksheet)EWorkbook.Worksheets.Item[1];
            EWorksheet.get_Range("A1", misValue).Formula = "UPC code";
            EWorksheet.get_Range("B1", misValue).Formula = "Link";
            Rng = EWorksheet.get_Range("A2", misValue).get_Resize(source.Count, misValue);
            Rng.NumberFormat = "00000000000000";
            int row = 2;

            foreach (KeyValuePair <Guid, string> pair in source)
            {
                EWorksheet.Cells[row, 1] = pair.Value;
                r.Load(pair.Key);
                Rng = EWorksheet.get_Range("B" + row, misValue);
                EWorksheet.Hyperlinks.Add(Rng, r.Fields.GetField <TextField>("Content Url").Value);
                //myExcelWorksheet.Cells[row, 2] = r.Fields.GetField<TextField>("Content Url").Value;
                row++;
            }
            ((Excel.Range)EWorksheet.Cells[2, 1]).EntireColumn.AutoFit();
            ((Excel.Range)EWorksheet.Cells[2, 2]).EntireColumn.AutoFit();
            EWorkbook.SaveAs(_fileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
                             Excel.XlSaveAsAccessMode.xlExclusive,
                             misValue, misValue, misValue, misValue, misValue);

            EWorkbook.Close(true, misValue, misValue);
            EApp.Quit();
            return(true);
        }
コード例 #5
0
        private string GetByte64Image()
        {
            Record rec = new Record((Application) Session["AdamApp"]);
            Guid recId;
            Guid.TryParse("7819340e-b66c-4225-a604-a54500a909b2", out recId);
            rec.Load(recId);

            IReadOnlyImage prev = rec.Files.Master.GetPreview();
            byte[] imagData = prev.GetBytes();
            string imageDataString = Convert.ToBase64String(imagData);
            return imageDataString;
        }
コード例 #6
0
        public FileContentResult GetFile()
        {
            Record rec = new Record((Application) Session["AdamApp"]);
            Guid recId;
            Guid.TryParse("7819340e-b66c-4225-a604-a54500a909b2", out recId);
            rec.Load(recId);

            IReadOnlyImage prev = rec.Files.Master.GetPreview();
            return new FileContentResult(prev.GetBytes(), "image/jpeg");
        }
コード例 #7
0
 void Start()
 {
     record = new Record();
     record.Load();
     currentState = State.Initial;
 }