コード例 #1
0
        /// <summary>
        /// Creates from table.
        /// </summary>
        /// <param name="fileTable">The file table.</param>
        /// <returns>The file data from a table object</returns>
        private string CreateFromTable(ITable fileTable)
        {
            var Builder   = new StringBuilder();
            var Seperator = "";

            if (fileTable.Columns.Count > 0)
            {
                foreach (var HeaderColumn in fileTable.Columns)
                {
                    Builder.Append(Seperator).Append("\"").Append(HeaderColumn?.Replace("\"", "") ?? "").Append("\"");
                    Seperator = ",";
                }
                Builder.AppendLine();
            }
            foreach (var Row in fileTable.Rows)
            {
                Seperator = "";
                foreach (var CurrentCell in Row.Cells)
                {
                    Builder.Append(Seperator).Append("\"").Append(CurrentCell.Content?.Replace("\"", "") ?? "").Append("\"");
                    Seperator = ",";
                }
                Builder.AppendLine();
            }
            return(Builder.ToString());
        }
コード例 #2
0
    /// <summary>
    /// Connect to the google spreadsheet and retrieves its header columns.
    /// </summary>
    protected override void Import()
    {
        if (scriptMachine.HasHeadColumn())
        {
            scriptMachine.HeaderColumnList.Clear();
        }

        Regex re = new Regex(@"\d+");

        DoCellQuery((cell) => {
            // get numerical value from a cell's address in A1 notation
            // only retrieves first column of the worksheet
            // which is used for member fields of the created data class.
            Match m = re.Match(cell.Title.Text);
            if (int.Parse(m.Value) > 1)
            {
                return;
            }

            // add cell's displayed value to the list.
            //fieldList.Add(new MemberFieldData(cell.Value.Replace(" ", "")));
            HeaderColumn header = new HeaderColumn();
            header.name         = cell.Value;
            scriptMachine.HeaderColumnList.Add(header);
        });

        EditorUtility.SetDirty(scriptMachine);
        AssetDatabase.SaveAssets();
    }
コード例 #3
0
    private void LoadColumnIntoGrid()
    {
        // create HeaderRow
        Ext.Net.HeaderRow row = new HeaderRow();
        int i = 0;

        foreach (var item in new SalaryBoardConfigController().GetSalaryColumnList(MenuID))
        {
            // set editor
            Ext.Net.TextField txtEditor = new TextField();
            txtEditor.MaskRe = "/[0-9.-]/";
            txtEditor.ID     = "txtEditor" + i;
            item.Editor.Add(txtEditor);

            grpSalaryBoard.ColumnModel.Columns.Add(item);

            #region Tạo GroupHeader
            // create HeaderColumn
            Ext.Net.HeaderColumn column = new HeaderColumn();
            column.AutoWidthElement = false;
            // tạo DisplayField để hiển thị
            Ext.Net.DisplayField dpf = new DisplayField();
            dpf.ID   = "dpf" + item.ColumnID;
            dpf.Text = "";
            // add DisplayField to ColumnHeader
            column.Component.Add(dpf);
            row.Columns.Add(column);
            #endregion

            i++;
        }
        lkv.HeaderRows.Add(row);
    }
コード例 #4
0
    /// <summary>
    /// Import the specified excel file and prepare to set type of each cell.
    /// </summary>
    protected override void Import()
    {
        base.Import();

        ExcelMachine machine = target as ExcelMachine;

        string path  = machine.excelFilePath;
        string sheet = machine.WorkSheetName;

        if (string.IsNullOrEmpty(path))
        {
            EditorUtility.DisplayDialog(
                "Error",
                "You should specify spreadsheet file first!",
                "OK"
                );
            return;
        }

        if (!File.Exists(path))
        {
            EditorUtility.DisplayDialog(
                "Error",
                "File at " + path + " does not exist.",
                "OK"
                );
            return;
        }

        if (machine.HasHeadColumn())
        {
            machine.HeaderColumnList.Clear();
        }

        var titles = new ExcelQuery(path, sheet).GetTitle();

        if (titles != null)
        {
            foreach (string s in titles)
            {
                HeaderColumn header = new HeaderColumn();
                header.name = s;
                machine.HeaderColumnList.Add(header);
            }
        }
        else
        {
            Debug.LogWarning("The WorkSheet [" + sheet + "] may be empty.");
        }

        EditorUtility.SetDirty(machine);
        AssetDatabase.SaveAssets();
    }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,dEs,Name")] HeaderColumn headerColumn, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                if (file == null || file.Length == 0)
                {
                    headerColumn.Image = "1.jpg";
                }
                else
                {
                    var uploadsRootFolder = Path.Combine(_environment.WebRootPath, "metro/img/product/AllProductImage/ProductColumn/");
                    if (!Directory.Exists(uploadsRootFolder))
                    {
                        Directory.CreateDirectory(uploadsRootFolder);
                    }
                    //جهت جلوگیری از نام تکراری فایل و جایگزینی
                    String guid = Guid.NewGuid().ToString();
                    headerColumn.Image = guid + file.FileName;
                    using (Image img = Image.FromStream(file.OpenReadStream()))
                    {
                        Stream ms = new MemoryStream(img.Resize(272, 334).ToByteArray());

                        //return new FileStreamResult(ms, "image/jpg");

                        var filePath = Path.Combine(uploadsRootFolder, guid + file.FileName);

                        using (var fileStream = new FileStream(filePath, FileMode.Create))
                        {
                            await ms.CopyToAsync(fileStream).ConfigureAwait(false);
                        }
                    }
                }

                _context.Add(headerColumn);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "HeaderColumnsDes", new { id = headerColumn.Id }));
            }
            return(View(headerColumn));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,dEs,Name")] HeaderColumn headerColumn, IFormFile file)
        {
            if (id != headerColumn.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //                    //جهت برطرف کردن خطای سازنده باز بودن ترک قبل از عملیات پردازش EF7 باز بودن ترک قبل از عملیات پردازش EF7
                    var original = _context.HeaderColumn.AsNoTracking().FirstOrDefault(p => p.Id == id);
                    if (file != null)
                    {
                        var           uploadsRootFolder = Path.Combine(_environment.WebRootPath, "metro/img/product/AllProductImage/ProductColumn/");
                        DirectoryInfo directory         = new DirectoryInfo(uploadsRootFolder);
                        //Directory.GetFiles(uploadsRootFolder + originalPerson.Image);
                        //چک میکنیم تا عکس پیش فرض رو پاک نکند
                        if (original.Image != "1.jpg")
                        {
                            foreach (FileInfo fileEF in directory.GetFiles())
                            {
                                if (fileEF.Name.Equals(original.Image))
                                {
                                    fileEF.Delete();
                                }
                            }
                        }
                        headerColumn.Image = file.FileName;
                        using (Image img = Image.FromStream(file.OpenReadStream()))
                        {
                            Stream ms = new MemoryStream(img.Resize(272, 334).ToByteArray());

                            //return new FileStreamResult(ms, "image/jpg");

                            var filePath = Path.Combine(uploadsRootFolder, file.FileName);

                            using (var fileStream = new FileStream(filePath, FileMode.Create))
                            {
                                await ms.CopyToAsync(fileStream).ConfigureAwait(false);
                            }
                        }
                    }
                    else
                    {
                        headerColumn.Image = original.Image;
                    }

                    _context.Update(headerColumn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HeaderColumnExists(headerColumn.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(headerColumn));
        }