Esempio n. 1
0
        public ActionResult CreateExcel()
        {
            var config = GetConfig();

            var report = new DevOpsReport(config);

            report.ExecEstimateReport(GetEstimateFile());

            var excel = new ExcelReport();

            excel.AddList(report.TaskEstimateReport, new Dictionary <string, string>());

            var bytes = excel.GetXlsFile();

            var key = $"Execl{Guid.NewGuid().ToString()}";

            TempData[key] = new TmpFile
            {
                FileName = "Оценка задач.xlsx",
                Content  = bytes
            };

            return(new JsonNetResult
            {
                Data = new
                {
                    key = key
                }
            });
        }
Esempio n. 2
0
        public void TestRaiFileEnsure()
        {   // this test does not really challange the delay caused by massive parallel change operations in Dropbox
            var f0 = new RaiFile($"{TestDir}/Data/EnsureTests/kill.txt");

            f0.mkdir();
            var f = new TextFile($"{TestDir}/Data/EnsureTests/kill.txt");

            for (int i = 0; i < 10000; i++)
            {
                f.Append("Test line " + i.ToString());
            }
            f.Save();
            var f2      = new RaiFile($"{TestDir}/Data/EnsureTests/kill2.txt");
            var start   = DateTimeOffset.UtcNow;
            var result1 = f2.cp(f);

            Assert.True(File.Exists(f2.FullName), "File is supposed to have materialized by now.");
            var cpDuration = DateTimeOffset.UtcNow - start;
            var f3         = new TmpFile();
            var result2    = f3.mv(f2);

            Assert.True(File.Exists(f3.FullName), "File is supposed to have materialized by now.");
            Assert.False(File.Exists(f2.FullName), "File is supposed to have vanished by now.");
            Assert.Equal(0, result1 + result2);
        }
Esempio n. 3
0
        public static Rectangle GetBounds(MapTile tile, TmpFile tmp)
        {
            tmp.Initialize();

            if (tile.SubTile >= tmp.Images.Count)
            {
                return(Rectangle.Empty);
            }
            var img = tmp.Images[tile.SubTile];

            int left   = tile.Dx * tmp.BlockWidth / 2;
            int top    = (tile.Dy - tile.Z) * tmp.BlockHeight / 2;
            int width  = tmp.BlockWidth;
            int height = tmp.BlockHeight;

            if (img.HasExtraData)
            {
                if (img.ExtraX < 0)
                {
                    left += img.ExtraX; width -= img.ExtraX;
                }
                if (img.ExtraY < 0)
                {
                    top += img.ExtraY; height -= img.ExtraY;
                }
                width  = Math.Max(width, img.ExtraWidth);
                height = Math.Max(height, img.ExtraHeight);
            }

            return(new Rectangle(left, top, width, height));
        }
Esempio n. 4
0
        //END Win32 Only
#endif

        //PUBLIC
        public virtual void SingleInstance.ISingleInstanceForm.HandleCommand(string strArgs)
        {
            string TmpFile;

            if (strArgs != "")
            {
                TmpFile = strArgs.TrimStart('?').TrimEnd(Chr(0));
                ConvertFile(TmpFile);
                //check if conversion is still running
                if (!FProcessing)
                {
                    //choose new destination
                    if (strArgs.StartsWith("?"))
                    {
                        if (!SetDestination(TmpFile.Substring(0, TmpFile.Length - Path.GetFileName(TmpFile).Length - 1)))
                        {
                            //user abort
                            return;
                        }
                    }
                    //restart the conversion
                    FProcessing       = true;
                    BtnCancel.Text    = "Cancel";
                    this.AcceptButton = null;
                    StartConversion(true);
                }
            }
        }
Esempio n. 5
0
 public override Stream OpenRead()
 {
     if (TmpFile == null)
     {
         return(null);
     }
     return(TmpFile.OpenRead());
 }
Esempio n. 6
0
 public override void MoveTo(string path, MoveToOptions opts)
 {
     if (opts.CanOverwrite && File.Exists(path))
     {
         File.Delete(path);
     }
     TmpFile.MoveTo(path);
 }
Esempio n. 7
0
 public override void Dispose()
 {
     if (log.IsDebugEnabled)
     {
         log.DebugFormat("In Dispose(): TmpFile.FullName = {0}", TmpFile.FullName);
     }
     if (TmpFile.Exists && TmpFile.FullName == (new FileInfo(tmpFileName)).FullName)
     {
         log.DebugFormat("Calling TmpFile.Delete()");
         TmpFile.Delete();
     }
 }
Esempio n. 8
0
        public void TmpFile_can_be_created_with_no_arguments()
        {
            var x = new TmpFile();

            Assert.NotNull(x);
            Assert.NotNull(x.FullPath);
            var folder    = Path.GetDirectoryName(x.FullPath) + Path.DirectorySeparatorChar;
            var filename  = Path.GetFileName(x.FullPath);
            var extension = Path.GetExtension(x.FullPath);

            Assert.That(folder, Is.EqualTo(Path.GetTempPath()));
            Assert.That(filename.Length, Is.GreaterThan(10));
            Assert.That(extension, Is.EqualTo(""));
            Assert.False(File.Exists(x.FullPath));
        }
Esempio n. 9
0
        public void TmpFile_can_be_created_given_only_extension(string[] input, string[] expected)
        {
            var x = new TmpFile(input[0]);

            Assert.NotNull(x);
            Assert.NotNull(x.FullPath);
            var fullPathFolder    = Path.GetDirectoryName(x.FullPath);
            var fullPathFileName  = Path.GetFileName(x.FullPath);
            var fullPathExtension = Path.GetExtension(x.FullPath);

            Assert.That(fullPathFolder, Is.EqualTo(Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar)));
            Assert.That(fullPathFileName.Length, Is.GreaterThan(10));
            Assert.That(fullPathExtension, Is.EqualTo(expected[0]));


            Assert.False(File.Exists(x.FullPath));
        }
Esempio n. 10
0
        public void FullPath_can_be_assigned_directly()
        {
            var x = new TmpFile();

            Assert.NotNull(x);
            Assert.That(x.Extension, Is.EqualTo(""));
            Assert.That(x.Filename.Length, Is.EqualTo(36));
            Assert.That(x.Folder, Is.EqualTo(Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar)));
            Assert.That(x.FullPath, Is.EqualTo(x.Folder + Path.DirectorySeparatorChar + x.Filename + x.Extension));

            x.FullPath = @"c:\dummyFolder\dummyFileName.dummyExtension";

            Assert.That(x.Extension, Is.EqualTo(".dummyExtension"));
            Assert.That(x.Filename, Is.EqualTo("dummyFileName"));
            Assert.That(x.Folder, Is.EqualTo(@"c:\dummyFolder"));
            Assert.That(x.FullPath, Is.EqualTo(@"c:\dummyFolder\dummyFileName.dummyExtension"));
        }
Esempio n. 11
0
        public ActionResult CreateExcel(DevOpsReportParams @params)
        {
            try
            {
                var config = GetConfig();

                var report = new DevOpsReport(config, GetCustomFieldsFile());

                report.ExecMainReport(@params);

                var excel = new ExcelReport();

                var criteria = new Dictionary <string, string>
                {
                    { "Период", $"{@params.Start:dd.MM.yyyy} - {(@params.End ?? DateTime.Now.Date):dd.MM.yyyy}" },
                    { "Сотрудники", string.Join(", ", config.Employees.Where(x => @params.Employees.Contains(x.Name)).Select(x => x.NameShort).OrderBy(x => x)) },
                };

                excel.AddList(report.ActivityReport, criteria);
                excel.AddList(report.TaskReport, criteria);
                excel.AddList(report.WorkingTimeReport, criteria);
                excel.AddList(report.WorkingTimeDiffReport, criteria);

                var bytes = excel.GetXlsFile();

                var key = $"Execl{Guid.NewGuid().ToString()}";

                TempData[key] = new TmpFile
                {
                    Content  = bytes,
                    FileName = "Аналитический отчет.xlsx"
                };

                return(new JsonNetResult
                {
                    Data = new
                    {
                        key = key
                    }
                });
            }
            catch (Exception e)
            {
                return(new ExceptionResult(e));
            }
        }
Esempio n. 12
0
        public void TmpFile_can_be_created_given_extension_and_folder(string[] input, string[] expected)
        {
            var x = new TmpFile(input[0], input[1]);

            Assert.NotNull(x);
            Assert.NotNull(x.FullPath);
            var fullPathFolder    = Path.GetDirectoryName(x.FullPath);
            var fullPathFileName  = Path.GetFileName(x.FullPath);
            var fullPathExtension = Path.GetExtension(x.FullPath);

            Assert.That(fullPathFolder, Is.EqualTo(expected[1]));
            Assert.That(fullPathFileName.Length, Is.GreaterThan(10));
            Assert.That(fullPathExtension, Is.EqualTo(expected[0]));


            Assert.False(File.Exists(x.FullPath));
        }
Esempio n. 13
0
        public void TmpFile_can_be_created_given_extension_folder_and_content(string[] input, string[] expected)
        {
            var testTools = new TestTools();

            var x = new TmpFile(input[0], input[1], input[2]);

            x.AssignTestTools(testTools);
            Assert.NotNull(x);
            Assert.NotNull(x.FullPath);
            var fullPathFolder    = Path.GetDirectoryName(x.FullPath);
            var fullPathFileName  = Path.GetFileName(x.FullPath);
            var fullPathExtension = Path.GetExtension(x.FullPath);

            Assert.That(fullPathFolder, Is.EqualTo(expected[1]));
            Assert.That(fullPathFileName.Length, Is.GreaterThan(10));
            Assert.That(fullPathExtension, Is.EqualTo(expected[0]));

            Assert.That(File.Exists(x.FullPath).ToString(), Is.EqualTo(expected[2]));
        }
Esempio n. 14
0
        public void If_TmpFile_points_to_a_existing_file_than_this_file_is_deleted_when_TmpFile_is_disposed()
        {
            var testTools = new TestTools();
            var filePath  = testTools.GetNewTmpFilePath(".txt");

            Assert.False(File.Exists(filePath));

            File.WriteAllText(filePath, "abc");

            Assert.True(File.Exists(filePath));

            var x = new TmpFile {
                FullPath = filePath
            };

            Assert.True(File.Exists(filePath));

            x.Dispose();

            Assert.False(File.Exists(filePath));
        }
Esempio n. 15
0
 public void AddTile(TmpFile tmpFile)
 {
     tmpFile.Initialize();
     TmpFiles.Add(tmpFile);
 }
Esempio n. 16
0
        unsafe public static void Draw(MapTile tile, TmpFile tmp, DrawingSurface ds)
        {
            tmp.Initialize();

            if (tile.SubTile >= tmp.Images.Count)
            {
                return;
            }
            TmpFile.TmpImage img = tmp.Images[tile.SubTile];
            var     zBuffer      = ds.GetZBuffer();
            var     heightBuffer = ds.GetHeightBuffer();
            Palette p            = tile.Palette;

            // calculate tile index -> pixel index
            Point offset = new Point(tile.Dx * tmp.BlockWidth / 2, (tile.Dy - tile.Z) * tmp.BlockHeight / 2);

            // make touched tiles (used for determining image cutoff)
            Point center         = offset + new Size(tmp.BlockWidth / 2, tmp.BlockHeight / 2);
            var   centerGridTile = tile.Layer.GetTileScreen(center, true, true);

            if (centerGridTile != null)
            {
                tile.Layer.GridTouched[centerGridTile.Dx, centerGridTile.Dy / 2]  |= TileLayer.TouchType.ByNormalData;
                tile.Layer.GridTouchedBy[centerGridTile.Dx, centerGridTile.Dy / 2] = tile;
            }

            Logger.Trace("Drawing TMP file {0} (subtile {1}) at ({2},{3})", tmp.FileName, tile.SubTile, offset.X, offset.Y);

            int stride = ds.BitmapData.Stride;

            int halfCx = tmp.BlockWidth / 2,
                halfCy = tmp.BlockHeight / 2;

            // writing bounds
            var   w_low  = (byte *)ds.BitmapData.Scan0;
            byte *w_high = (byte *)ds.BitmapData.Scan0 + stride * ds.BitmapData.Height;
            byte *w      = (byte *)ds.BitmapData.Scan0 + stride * offset.Y + (offset.X + halfCx - 2) * 3;

            int rIdx = 0, x, y = 0;
            int zIdx = offset.Y * ds.Width + offset.X + halfCx - 2;
            int cx   = 0;           // Amount of pixel to copy

            for (; y < halfCy; y++)
            {
                cx += 4;
                for (ushort c = 0; c < cx; c++)
                {
                    byte paletteValue = img.TileData[rIdx];

                    short zBufVal = (short)((tile.Rx + tile.Ry) * tmp.BlockHeight / 2 - (img.ZData != null ? img.ZData[rIdx] : 0));
                    if (paletteValue != 0 && w_low <= w && w < w_high && zBufVal >= zBuffer[zIdx])
                    {
                        *(w + 0)           = p.Colors[paletteValue].B;
                        *(w + 1)           = p.Colors[paletteValue].G;
                        *(w + 2)           = p.Colors[paletteValue].R;
                        zBuffer[zIdx]      = zBufVal;
                        heightBuffer[zIdx] = (short)(tile.Z * Drawable.TileHeight / 2);
                    }
                    w += 3;
                    zIdx++;
                    rIdx++;
                }
                w    += stride - 3 * (cx + 2);
                zIdx += ds.Width - (cx + 2);
            }

            w    += 12;
            zIdx += 4;
            for (; y < tmp.BlockHeight; y++)
            {
                cx -= 4;
                for (ushort c = 0; c < cx; c++)
                {
                    byte paletteValue = img.TileData[rIdx];

                    short zBufVal = (short)((tile.Rx + tile.Ry) * tmp.BlockHeight / 2 - (img.ZData != null ? img.ZData[rIdx] : 0));
                    if (paletteValue != 0 && w_low <= w && w < w_high && zBufVal >= zBuffer[zIdx])
                    {
                        *(w + 0)           = p.Colors[paletteValue].B;
                        *(w + 1)           = p.Colors[paletteValue].G;
                        *(w + 2)           = p.Colors[paletteValue].R;
                        zBuffer[zIdx]      = zBufVal;
                        heightBuffer[zIdx] = (short)(tile.Z * Drawable.TileHeight / 2);
                    }
                    w += 3;
                    zIdx++;
                    rIdx++;
                }
                w    += stride - 3 * (cx - 2);
                zIdx += ds.Width - (cx - 2);
            }

            if (!img.HasExtraData)
            {
                return;                                // we're done now
            }
            offset.X += img.ExtraX - img.X;
            offset.Y += img.ExtraY - img.Y;
            w         = w_low + stride * offset.Y + 3 * offset.X;
            zIdx      = offset.X + offset.Y * ds.Width;
            rIdx      = 0;

            // identify extra-data affected tiles for cutoff
            var extraScreenBounds = Rectangle.FromLTRB(
                Math.Max(0, offset.X), Math.Max(0, offset.Y),
                Math.Min(offset.X + img.ExtraWidth, ds.Width), Math.Min(offset.Y + img.ExtraHeight, ds.Height));

            for (int by = extraScreenBounds.Top; by < extraScreenBounds.Bottom; by += tmp.BlockHeight / 2)
            {
                for (int bx = extraScreenBounds.Left; bx < extraScreenBounds.Right; bx += tmp.BlockWidth / 2)
                {
                    var gridTileNoZ = tile.Layer.GetTileScreen(new Point(bx, by), true, true);
                    if (gridTileNoZ != null)
                    {
                        Logger.Trace("Tile at ({0},{1}) has extradata affecting ({2},{3})", tile.Dx, tile.Dy, gridTileNoZ.Dx,
                                     gridTileNoZ.Dy);
                        tile.Layer.GridTouched[gridTileNoZ.Dx, gridTileNoZ.Dy / 2]  |= TileLayer.TouchType.ByExtraData;
                        tile.Layer.GridTouchedBy[gridTileNoZ.Dx, gridTileNoZ.Dy / 2] = tile;
                    }
                }
            }

            // Extra graphics are just a square
            for (y = 0; y < img.ExtraHeight; y++)
            {
                for (x = 0; x < img.ExtraWidth; x++)
                {
                    // Checking per line is required because v needs to be checked every time
                    byte  paletteValue = img.ExtraData[rIdx];
                    short zBufVal      = (short)((tile.Rx + tile.Ry) * tmp.BlockHeight / 2 + (img.ExtraZData != null ? img.ExtraZData[rIdx] : 0));

                    if (paletteValue != 0 && w_low <= w && w < w_high && zBufVal >= zBuffer[zIdx])
                    {
                        *w++ = p.Colors[paletteValue].B;
                        *w++ = p.Colors[paletteValue].G;
                        *w++ = p.Colors[paletteValue].R;
                        zBuffer[zIdx]      = zBufVal;
                        heightBuffer[zIdx] = (short)(img.ExtraHeight - y + tile.Z * Drawable.TileHeight / 2);
                    }
                    else
                    {
                        w += 3;
                    }
                    zIdx++;
                    rIdx++;
                }
                w    += stride - img.ExtraWidth * 3;
                zIdx += ds.Width - img.ExtraWidth;
            }
        }
Esempio n. 17
0
 public void AddTile(TmpFile tmpFile)
 {
     TmpFiles.Add(tmpFile);
 }
        public override void Save()
        {
            if (docControl == null || !docControl.ImageDisplayed || ServerInfo == null)
            {
                return;
            }

            string  oldFileName;
            TmpFile tf = null;

            // Добавил сохранения изменений изображения из факса.
            if (IsFax() && docControl.Modified)
            {
                oldFileName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
                if (!docControl.SaveAs(oldFileName))
                {
                    return;
                }
            }
            else
            {
                tf          = Environment.GetTmpFileByKey(docControl.FileName);
                oldFileName = docControl.FileName;
                if (tf != null && tf.CurAct == Environment.ActionBefore.Save)
                {
                    if (!File.Exists(tf.TmpFullName))
                    {
                        docControl.SaveToTmpCopy(docControl.FileName, tf.TmpFullName, docControl.IsPDFMode);
                    }

                    oldFileName = tf.TmpFullName;
                }
            }

            if (Environment.DocToSave.ContainsKey(oldFileName))
            {
                Form dialog = Environment.DocToSave[oldFileName] as Form;
                if (dialog != null)
                {
                    dialog.BringToFront();
                    dialog.Activate();
                }
            }
            else
            {
                if (File.Exists(oldFileName))
                {
                    Environment.DocToSave.TryAdd(oldFileName, null);
                    Form findForm = docControl.FindForm();
                    if (findForm != null && findForm.InvokeRequired)
                    {
                        findForm.Invoke((MethodInvoker)(delegate
                        {
                            Dialogs.AddDBDocDialog dialog = new Dialogs.AddDBDocDialog(serverInfo, Dialogs.AddDBDocDialog.TypeSave.SaveAll,
                                                                                       RetrieveScanDate(), IsFax(), ID, docControl.CurDocString,                                         //GetStringToSave(),
                                                                                       IsFax(), IsScaner(), oldFileName, saveFaxInfo, null,
                                                                                       IsPdf, docControl.PageCount);
                            Environment.DocToSave.TryUpdate(oldFileName, dialog, null);

                            if (tf == null || tf.CurAct == Environment.ActionBefore.Save)
                            {
                                if (tf == null)
                                {
                                    tf = Environment.GetTmpFile(oldFileName);
                                }
                                if (tf != null)
                                {
                                    tf.LinkCnt++;
                                }
                            }

                            dialog.DialogEvent += dialog_DialogEvent;
                            dialog.Show();
                        }));
                    }
                    else
                    {
                        Dialogs.AddDBDocDialog dialog = new Dialogs.AddDBDocDialog(serverInfo, Dialogs.AddDBDocDialog.TypeSave.SaveAll,
                                                                                   RetrieveScanDate(), IsFax(), ID,
                                                                                   docControl.CurDocString,        //GetStringToSave(),
                                                                                   IsFax(), IsScaner(),
                                                                                   oldFileName, saveFaxInfo, null, IsPdf,
                                                                                   docControl.PageCount);
                        Environment.DocToSave.TryUpdate(oldFileName, dialog, null);

                        if (tf == null || tf.CurAct == Environment.ActionBefore.Save)
                        {
                            if (tf == null)
                            {
                                tf = Environment.GetTmpFile(oldFileName);
                            }
                            if (tf != null)
                            {
                                tf.LinkCnt++;
                            }
                        }

                        dialog.DialogEvent += dialog_DialogEvent;
                        dialog.Show();
                    }
                }
            }
        }
Esempio n. 19
0
 public override Stream CreateStream()
 {
     return(TmpFile.Create());
 }