Ejemplo n.º 1
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings         = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     CheckAndConnectJira();
     UpdateJiraProjectCache();
 }
Ejemplo n.º 2
0
        internal static void ExportView(string viewName, string path, IExportSettings options)
        {
            ExportEngine ee = new ExportEngine();

            ee.ExportView(viewName, path, options);
            ee.Close(); // does nothing, not needed
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method is called by all exports methods, it takes care of all the actual exports.
        /// Other export methods are really just preparation routines for calling this method.
        /// </summary>
        /// <param name="cur">ICommenceCursor</param>
        /// <param name="fileName">file name</param>
        /// <param name="settings">IExportSettings</param>
        internal void ExportCursor(ICommenceCursor cur, string fileName, IExportSettings settings)
        {
            // exporting may take a long time, and the system may go into power saving mode
            // this is annoying, so we tell the system not to go into sleep/hibernation
            // this may or may not be a good idea...
            PowerSavings ps = new PowerSavings();

            try
            {
                ps.EnableConstantDisplayAndPower(true, "Performing time-consuming Commence export");
                cur.MaxFieldSize = this.Settings.MaxFieldSize; // remember setting this size greatly impacts memory usage!

                using (_writer = this.GetExportWriter(cur, settings))
                {
                    SubscribeToWriterEvents(_writer);
                    _writer.WriteOut(fileName);
                }
            }
            finally
            {
                ps.EnableConstantDisplayAndPower(false); // CODE SMELL, may overwrite things
                UnsubscribeToWriterEvents(_writer);
                _writer?.Dispose();
            }
        }
Ejemplo n.º 4
0
 public ExcelWriterUsingOpenXml(ICommenceCursor cursor, IExportSettings settings) : base(cursor, settings)
 {
     columnDefinitions            = new List <ColumnDefinition>(_settings.UseThids ? base.ColumnDefinitions.Skip(1) : base.ColumnDefinitions);
     _sheetName                   = string.IsNullOrEmpty(settings.CustomRootNode) ? Utils.EscapeString(_dataSourceName, "_").Left(MaxSheetNameLength) : settings.CustomRootNode;
     settings.ISO8601Format       = true;  // override custom setting(s)
     settings.SplitConnectedItems = false; // override custom setting(s)
 }
        private void BtnPrintBarCode_Click_Extend(object sender, EventArgs e)
        {
            this.Model.ClearErrorMessage();
            try
            {
                IList <IUIRecord> selectedRecords = this.Model.ProductBarCode.Cache.GetSelectRecord();
                if (selectedRecords == null || selectedRecords.Count == 0)
                {
                    throw new Exception("没有选择需要打印条码的记录!");
                }

                UIActionEventArgs args     = new UIActionEventArgs();
                IExportSettings   settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();
                settings.PrintTemplateCatalogType = printTemplateCatalogType;
                settings.UserDataCallBack         = DataCallBackHandle;
                // 打印完成委托
                settings.OnFinished = new FinishCallBackHandle(FinishCallBackHandle);
                args.Tag            = settings;

                CommandFactory.DoCommand("OnPrint", this.Action, sender, args);
            }
            catch (Exception ex)
            {
                IUIModel model = this.Model;
                this.Model.ErrorMessage.SetErrorMessage(ref model, ex.Message);
            }
            BtnPrintBarCode_Click_DefaultImpl(sender, e);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Transform the images ready for download, optionally adding a watermark.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="waterMarkText"></param>
        public void TransformDownloadImageSync(string input, Stream output, IExportSettings config)
        {
            using SKImage img = SKImage.FromEncodedData(input);
            using var bitmap  = SKBitmap.FromImage(img);

            float maxSize      = config.MaxImageSize;
            var   resizeFactor = 1f;

            if (bitmap.Width > maxSize)
            {
                resizeFactor = maxSize / bitmap.Width;
            }
            else if (bitmap.Height > maxSize)
            {
                resizeFactor = maxSize / bitmap.Height;
            }

            var targetWidth  = (int)Math.Round(bitmap.Width * resizeFactor);
            var targetHeight = (int)Math.Round(bitmap.Height * resizeFactor);

            // First create a bitmap the right size.
            using var toBitmap = new SKBitmap(targetWidth, targetHeight, bitmap.ColorType, bitmap.AlphaType);
            using var canvas   = new SKCanvas(toBitmap);

            // Draw a bitmap rescaled
            canvas.SetMatrix(SKMatrix.CreateScale(resizeFactor, resizeFactor));
            canvas.DrawBitmap(bitmap, 0, 0);
            canvas.ResetMatrix();

            if (!string.IsNullOrEmpty(config.WatermarkText))
            {
                using var font  = SKTypeface.FromFamilyName("Arial");
                using var brush = new SKPaint
                      {
                          Typeface    = font,
                          TextSize    = 64.0f,
                          IsAntialias = true,
                          Color       = new SKColor(255, 255, 255, 255)
                      };

                var textWidth       = brush.MeasureText(config.WatermarkText);
                var textTargetWidth = targetWidth / 6f;
                var fontScale       = textTargetWidth / textWidth;

                brush.TextSize *= fontScale;

                // Offset by text width + 10%
                var rightOffSet = (textTargetWidth * 1.1f);

                canvas.DrawText(config.WatermarkText, targetWidth - rightOffSet, targetHeight - brush.TextSize, brush);
            }

            canvas.Flush();

            using var image = SKImage.FromBitmap(toBitmap);
            using var data  = image.Encode(SKEncodedImageFormat.Jpeg, 90);

            data.SaveTo(output);
        }
 internal SQLiteToXmlSerializer(IExportSettings settings,
                                DataTable primaryTable,
                                string connectionString)
 {
     _settings     = settings;
     _cs           = connectionString;
     _primaryTable = primaryTable;
 }
Ejemplo n.º 8
0
 public SettingsCollection()
 {
     AppSettings            = new AppSettings();
     JiraConnectionSettings = new JiraConnectionSettings();
     UiSettings             = new UiSettings();
     InternalSettings       = new InternalSettings();
     ExportSettings         = new ExportSettings();
 }
Ejemplo n.º 9
0
 public SettingsCollection(IAppSettings appSettings, IJiraConnectionSettings jiraConnectionSettings, IUiSettings uiSettings, IInternalSettings internalSettings, IExportSettings exportSettings)
 {
     AppSettings            = appSettings;
     JiraConnectionSettings = jiraConnectionSettings;
     UiSettings             = uiSettings;
     InternalSettings       = internalSettings;
     ExportSettings         = exportSettings;
 }
Ejemplo n.º 10
0
 public SettingsCollection()
 {
     AppSettings = new AppSettings();
     JiraConnectionSettings = new JiraConnectionSettings();
     UiSettings = new UiSettings();
     InternalSettings = new InternalSettings();
     ExportSettings = new ExportSettings();
 }
Ejemplo n.º 11
0
 public SettingsCollection(IAppSettings appSettings, IJiraConnectionSettings jiraConnectionSettings, IUiSettings uiSettings, IInternalSettings internalSettings, IExportSettings exportSettings)
 {
     AppSettings = appSettings;
     JiraConnectionSettings = jiraConnectionSettings;
     UiSettings = uiSettings;
     InternalSettings = internalSettings;
     ExportSettings = exportSettings;
 }
Ejemplo n.º 12
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings         = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     Task.Factory.StartNew(UpdateJiraProjectCache);
 }
 internal SQLiteToJsonSerializer(IExportSettings settings,
                                 OriginalCursorProperties ocp,
                                 DataTable primaryTable,
                                 string connectionString)
 {
     _settings     = settings;
     _ocp          = ocp;
     _cs           = connectionString;
     _primaryTable = primaryTable;
 }
Ejemplo n.º 14
0
        public SettingsCollection(ISettingsCollection settings)
        {
            AppSettings            = settings.AppSettings;
            JiraConnectionSettings = settings.JiraConnectionSettings;
            UiSettings             = settings.UiSettings;
            InternalSettings       = settings.InternalSettings;
            ExportSettings         = settings.ExportSettings;

            isIntialised = false;
        }
Ejemplo n.º 15
0
    /// <summary>
    /// Convert an image, optionally watermarking.
    /// </summary>
    /// <param name="input"></param>
    /// <param name="output"></param>
    /// <param name="config"></param>
    /// TODO: Async
    public async Task TransformDownloadImage(string input, Stream output, IExportSettings exportConfig)
    {
        var ext = Path.GetExtension(input);

        var processor = _factory.GetProcessor(ext);

        if (processor != null)
        {
            await processor.TransformDownloadImage(input, output, exportConfig);
        }
    }
Ejemplo n.º 16
0
        public void Initialise()
        {
            var settings = SettingsCollectionSerializer.DeSerialize();

            AppSettings            = settings.AppSettings;
            JiraConnectionSettings = settings.JiraConnectionSettings;
            UiSettings             = settings.UiSettings;
            InternalSettings       = settings.InternalSettings;
            ExportSettings         = settings.ExportSettings;

            isIntialised = true;
        }
Ejemplo n.º 17
0
        public static async Task ExportAsync(this ISession session, IExportSettings settings, ILogger log, Func <DynamicContent, Task> handler)
        {
            var ctx = QueryContext.Default.Unpublished(settings.Unpublished);

            var contents = session.Contents(settings.Schema);

            var total       = 0L;
            var totalRead   = 0;
            var currentPage = 0;

            var handled = new HashSet <string>();

            using (var logLine = log.WriteSameLine())
            {
                do
                {
                    var query = new ContentQuery
                    {
                        Filter  = settings.Filter,
                        OrderBy = settings.OrderBy,
                        Search  = settings.FullText,
                        Skip    = currentPage * 100,
                        Top     = 100
                    };

                    var content = await contents.GetAsync(query, ctx);

                    total = content.Total;

                    if (content.Items.Count == 0)
                    {
                        break;
                    }

                    foreach (var entity in content.Items)
                    {
                        if (handled.Add(entity.Id))
                        {
                            totalRead++;

                            await handler(entity);

                            logLine.WriteLine("> Exported: {0} of {1}.", totalRead, total);
                        }
                    }

                    currentPage++;
                }while (totalRead < total);
            }

            log.WriteLine("> Exported: {0} of {1}. Completed.", totalRead, total);
        }
Ejemplo n.º 18
0
        private void CustomerItemPrint_Click(object sender, EventArgs e)
        {
            //输出服务
            IExportSettings settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();

            //最末一级分类目录的实体key
            settings.PrintTemplateCatalogType = "UFIDA.U9.CBO.SCM.Customer.CustomerItem";
            //从GetPrintDataNew()方法取数
            settings.UserDataCallBack = new DataCallBackHandle(this.GetPrintDataNew);
            UIActionEventArgs ex = new UIActionEventArgs();

            ex.Tag = settings;
            UFIDA.U9.UI.Commands.CommandFactory.DoCommand("OnPrint", (BaseAction)part.Action, sender, ex);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructor used when exporting cursor.
 /// </summary>
 /// <param name="cursor">Database.ICommenceCursor.</param>
 /// <param name="settings">ExportSettings object.</param>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ArgumentException"></exception>
 protected internal BaseWriter(ICommenceCursor cursor,
                               IExportSettings settings)
 {
     _cursor   = cursor;
     _settings = settings;
     // this check is very important
     if (_settings.HeaderMode == HeaderMode.CustomLabel)
     {
         if (ValidCustomHeaders(_settings.CustomHeaders.Select(x => x.ToString()).ToArray()))
         {
             _customColumnHeaders = _settings.CustomHeaders.Select(x => x.ToString()).ToArray();
             _customColumnHeaders = Utils.RenameDuplicates(_customColumnHeaders.ToList()).ToArray();
         }
     }
     _dataSourceName = (string.IsNullOrEmpty(_cursor.View)) ? _cursor.Category : _cursor.View;
     _cursor.SeekRow(CmcCursorBookmark.Beginning, 0); // put rowpointer on first item
 }
Ejemplo n.º 20
0
 internal DataReader(ICommenceCursor cursor, IExportSettings settings, List <ColumnDefinition> columndefinitions)
 {
     this.cursor   = (CommenceCursor)cursor;
     totalRows     = cursor.RowCount;
     this.settings = settings;
     numRows       = (int)Math.Pow(2, BalanceNumRowsAndFieldSize(settings));
     if (settings.NumRows < numRows)
     {
         numRows = settings.NumRows;
     }
     this.columnDefinitions = columndefinitions;
     regex = new Regex(pattern);
     if (this.cursor.Flags.HasFlag(CmcOptionFlags.UseThids))
     {
         useThids = true;
     }
 }
Ejemplo n.º 21
0
        /// <inheritdoc />
        public void ExportView(string viewName, string fileName, IExportSettings settings = null)
        {
            if (settings != null)
            {
                this.Settings = settings;
            }                                                   // use user-supplied settings

            using (var db = new CommenceDatabase())
            {
                string _viewName = string.IsNullOrEmpty(viewName) ? GetActiveViewName(db) : viewName;
                using (ICommenceCursor cur = db.GetCursor(_viewName, CmcCursorType.View, this.Settings.UseThids
                    ? CmcOptionFlags.UseThids
                    : CmcOptionFlags.Default))
                {
                    ExportCursor(cur, fileName, this.Settings);
                }
            }
        }
        private void BtnPrintBarCode_Click_Extend(object sender, EventArgs e)
        {
            this.Model.ClearErrorMessage();
            IList <IUIRecord> selectedRecords = this.Model.CompleteApplyBarCode.Cache.GetSelectRecord();

            if (selectedRecords == null || selectedRecords.Count == 0)
            {
                IUIModel model = this.Model;
                this.Model.ErrorMessage.SetErrorMessage(ref model, "没有选择需要打印条码的记录!");
                return;
            }

            bool checkFail = false;

            foreach (CompleteApplyBarCodeRecord selectedRecord in selectedRecords)
            {
                //打印外包装允许可以打印条码2次,否则只能允许打印1次
                if (((selectedRecord.IsPrintWrapper ?? false) && selectedRecord.PrintCount >= 2) || (!(selectedRecord.IsPrintWrapper ?? false) && selectedRecord.PrintCount >= 1))
                {
                    IUIRecord record       = selectedRecord;
                    string    errorMessage = string.Format("条码{0}已经超出打印次数,不允许打印", selectedRecord.BarCode);
                    this.Model.ErrorMessage.SetErrorMessage(ref record, "", errorMessage);
                    checkFail = true;
                }
            }
            if (checkFail)
            {
                return;
            }

            UIActionEventArgs args     = new UIActionEventArgs();
            IExportSettings   settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();

            settings.PrintTemplateCatalogType = printTemplateCatalogType;
            settings.UserDataCallBack         = DataCallBackHandle;
            // 打印完成委托
            settings.OnFinished = new FinishCallBackHandle(FinishCallBackHandle);
            args.Tag            = settings;

            CommandFactory.DoCommand("OnPrint", this.Action, sender, args);

            BtnPrintBarCode_Click_DefaultImpl(sender, e);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Factory method for creating the required export writer object for a cursor export.
        /// </summary>
        /// <param name="cursor">Database.ICommenceCursor .</param>
        /// <param name="settings">Settings object.</param>
        /// <returns>Derived BaseDataWriter object.</returns>
        /// <remarks>Defaults to XML.</remarks>
        internal BaseWriter GetExportWriter(ICommenceCursor cursor, IExportSettings settings)
        {
            if (!settings.PreserveAllConnections && settings.NestConnectedItems && settings.ExportFormat == ExportFormat.Json)
            {
                return(new AdoNetWriter(cursor, settings)); // i think this can be taken out entirely
            }
            if (settings.PreserveAllConnections)
            {
                return(new Complex.SQLiteWriter(cursor, settings));
            }

            switch (settings.ExportFormat)
            {
            case ExportFormat.Text:
                return(new TextWriter(cursor, settings));

            case ExportFormat.Html:
                return(new HtmlWriter(cursor, settings));

            case ExportFormat.Xml:
                return(new XmlWriter(cursor, settings));

            case ExportFormat.Json:
                return(new JsonWriter(cursor, settings));

            case ExportFormat.Excel:
                //_writer = new ExcelWriterUsingXml(cursor, settings);
                //return new ExcelWriterUsingOleDb(cursor, settings);
                //return new ExcelWriterUsingOpenXml(cursor, settings);
                return(new ExcelWriterUsingEPPlus(cursor, settings));

            case ExportFormat.Event:
                return(new EventWriter(cursor, settings));

            case ExportFormat.GoogleSheets:
                // will probably always be too slow
                throw new NotImplementedException("Exportformat not yet implemented.");

            default:
                return(new XmlWriter(cursor, settings));
            }
        }
        internal ExcelWriterUsingEPPlus(ICommenceCursor cursor, IExportSettings settings)
            : base(cursor, settings)
        {
            string s = string.IsNullOrEmpty(settings.CustomRootNode) ? _dataSourceName : settings.CustomRootNode;

            _dataTable                   = PrepareDataTable(s, base.ColumnDefinitions);
            _sheetName                   = Utils.EscapeString(s, "_").Left(MaxSheetNameLength);
            settings.Canonical           = true;  // override custom setting
            settings.SplitConnectedItems = false; // override custom setting
            // When dealing with very large cursors,
            // the default number of rows read may lead to memory issues when dumping to a datatable
            // we may have to cap the number of items being read
            // This superceeds the check already performed in the datareader.
            // I am undecided on this.
            // What I do know is that writing 1000 rows of 250 columns of size 30.000
            // (i.e. 250 large text fields, fully populated) will fail.
            // Maybe we should have some mechanism that collects the size of the fields
            // then caps the NumRows count accordingly.
            // However, it would not solve issues with EPPlus running out of memory when dealing with huge workbooks.
        }
Ejemplo n.º 25
0
        public ExportModel(JiraTimer timer, TimeSpan? exportTime, IExportSettings exportSettings)
        {
            UpdateTimer(timer, exportTime);

            ExportDate = timer.DateStarted.Date != DateTime.Now.Date ? timer.DateStarted.Date.AddHours(12) : DateTime.Now;

            switch (exportSettings.DefaultRemainingValue)
            {
                case DefaultRemaining.Auto:
                    WorkLogStrategy = WorkLogStrategy.Automatic;
                    break;
                case DefaultRemaining.Leave:
                    WorkLogStrategy = WorkLogStrategy.LeaveRemaining;
                    break;
                case DefaultRemaining.Set:
                    WorkLogStrategy = WorkLogStrategy.SetValue;
                    break;
            }

            DefaultComment = exportSettings.EmptyExportComment;
        }
Ejemplo n.º 26
0
        /// <inheritdoc />
        public void ExportCategory(string categoryName, string fileName, IExportSettings settings = null)
        {
            if (settings != null)
            {
                this.Settings = settings;
            }                                                   // use custom settings if supplied
            CmcOptionFlags flags = this.Settings.UseThids
                ? CmcOptionFlags.UseThids
                : CmcOptionFlags.Default | CmcOptionFlags.IgnoreSyncCondition;

            // User requested we skip connections.
            // A default cursor on a category contains all fields *and* connections.
            // The data receiving routines will ignore them, but they will be read unless we do not include them in our cursor
            // We optimize here by only including direct fields in the cursor
            using (var db = new CommenceDatabase())
            {
                if (this.Settings.SkipConnectedItems && this.Settings.HeaderMode != HeaderMode.CustomLabel)
                {
                    using (ICommenceCursor cur = GetCategoryCursorFieldsOnly(db, categoryName, flags))
                    {
                        // we can limit MAX_FIELD_SIZE in this case
                        this.Settings.MaxFieldSize = (int)Math.Pow(2, 15); // 32.768‬, the built-in Commence max fieldlength (large text) is 30.000
                        ExportCursor(cur, fileName, this.Settings);
                    }
                }
                else
                {
                    using (ICommenceCursor cur = GetCategoryCursorAllFieldsAndConnections(db, categoryName, flags))
                    {
                        // You can create a cursor with all fields including connections by just
                        // supplying CmcOptionFlags.All.
                        // However, when the cursor is read, connected items are returned as comma-delimited strng,
                        // which, because Commence does not supply text-qualifiers, makes it impossible to split them.
                        // We therefore explicitly set the connections which deteriorates performance
                        // but gains us (more) reliability.
                        ExportCursor(cur, fileName, this.Settings);
                    }
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Transforms an image to add a watermark.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="waterMarkText"></param>
        public async Task TransformDownloadImage(string input, Stream output, IExportSettings config)
        {
            Logging.Log($" Running image transform for Watermark: {config.WatermarkText}");

            using var img = Image.Load(input, out IImageFormat fmt);

            if (config.Size != ExportSize.FullRes)
            {
                int maxSize = config.MaxImageSize;

                var opts = new ResizeOptions {
                    Mode = ResizeMode.Max,
                    Size = new Size {
                        Height = maxSize, Width = maxSize
                    },
                    Sampler = KnownResamplers.Lanczos3
                };

                // Rotate and resize.
                img.Mutate(x => x.AutoOrient().Resize(opts));
            }
            else
            {
                // Just rotate.
                img.Mutate(x => x.AutoOrient());
            }

            if (!string.IsNullOrEmpty(config.WatermarkText) && fontCollection != null)
            {
                // Apply the watermark if one's been specified.
                var fontFamily = fontCollection.Get("Arial");
                var font       = fontFamily.CreateFont(10);

                img.Mutate(context => ApplyWaterMark(context, font, config.WatermarkText, Color.White));
            }

            await img.SaveAsync(output, fmt);
        }
Ejemplo n.º 28
0
        private int BalanceNumRowsAndFieldSize(IExportSettings settings)
        {
            /* If the maxfieldsize is very large, decrease the number of rows being read.
             * This is largely untested.
             */
            int maxpower  = 20;
            int threshold = (int)Math.Pow(2, maxpower);
            int i         = 10;

            if (threshold < settings.MaxFieldSize)
            {
                while (Math.Pow(2, maxpower) < settings.MaxFieldSize)
                {
                    i--;
                    maxpower++;
                    if (i == 0)
                    {
                        break;
                    }
                }
            }
            return(i);
        }
Ejemplo n.º 29
0
        public ExportModel(JiraTimer timer, TimeSpan?exportTime, IExportSettings exportSettings)
        {
            UpdateTimer(timer, exportTime);

            ExportDate = timer.DateStarted.Date != DateTime.Now.Date ? timer.DateStarted.Date.AddHours(12) : DateTime.Now;

            switch (exportSettings.DefaultRemainingValue)
            {
            case DefaultRemaining.Auto:
                WorkLogStrategy = WorkLogStrategy.Automatic;
                break;

            case DefaultRemaining.Leave:
                WorkLogStrategy = WorkLogStrategy.LeaveRemaining;
                break;

            case DefaultRemaining.Set:
                WorkLogStrategy = WorkLogStrategy.SetValue;
                break;
            }

            DefaultComment = exportSettings.EmptyExportComment;
        }
 internal ExcelWriterUsingOleDb(ICommenceCursor cursor, IExportSettings settings) : base(cursor, settings)
 {
     columnDefinitions = new List <ColumnDefinition>(_settings.UseThids ? base.ColumnDefinitions.Skip(1) : base.ColumnDefinitions);
 }
Ejemplo n.º 31
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     Task.Factory.StartNew(UpdateJiraProjectCache);
 }
Ejemplo n.º 32
0
 internal JiraTimerCollection(IExportSettings exportSettings)
 {
     this.exportSettings = exportSettings;
     timerList = JiraTimerCollectionSerializer.DeSerialize();
 }
Ejemplo n.º 33
0
        ///////////////////////////////////////////////////////////////////////

        //public string getFilePath()
        //{
        //    object tmp = LightFieldApplication.Experiment.GetValue(ExperimentSettings.FileNameGenerationFileFormatLocation);
        //    if (tmp == null)
        //    {
        //        return "Null object";
        //    }
        //    else
        //    {
        //        return tmp.ToString();
        //    }
        //}
        ///////////////////////////////////////////////////////////////////////
        private void Export_Tiff(string sourceFilename)
        {
            // Get the file manager
            IFileManager fm = LightFieldApplication.FileManager;

            // Block User Pop Ups
            LightFieldApplication.UserInteractionManager.SuppressUserInteraction = true;

            try
            {
                // Add Files
                List <string> itemsForExport = new List <string>();
                itemsForExport.Add(sourceFilename);

                IList <IExportSelectionError> selectedErrors = new List <IExportSelectionError>();

                ITiffExportSettings tifSettings = (ITiffExportSettings)fm.CreateExportSettings(ExportFileType.Tiff);

                // Specifics
                tifSettings.IncludeAllExperimentInformation = true;

                IExportSettings baseSettings_ = null;

                baseSettings_ = tifSettings;

                ExportOutputPathOption options_ = ExportOutputPathOption.InputPath;

                // Common Settings for all types
//                baseSettings_.CustomOutputPath = customPath_;
                baseSettings_.OutputPathOption = options_;
                baseSettings_.OutputMode       = (ExportOutputMode)Enum.Parse(typeof(ExportOutputMode), "OneFilePerFrame");

                selectedErrors = baseSettings_.Validate(itemsForExport);

                // Busy cursor during write
                using (new AddInStatusHelper(LightFieldApplication, ApplicationBusyStatus.Busy))
                {
                    fm.Export(baseSettings_, itemsForExport);
                }


                //// Async Mode
                //if (AsyncCheckBox.IsChecked == true)
                //{
                //    fm.ExportCompleted += new EventHandler<ExportCompletedEventArgs>(fm_ExportCompleted);

                //    application_.UserInteractionManager.ApplicationBusyStatus = ApplicationBusyStatus.Busy;
                //    fm.ExportAsync(baseSettings_, itemsForExport);

                //    // Enable cancel
                //    CancelButton.IsEnabled = true;
                //    ExportButton.IsEnabled = false;
                //}
                //// Sync Mode
                //else
                //{
                //    ExportButton.IsEnabled = false;

                //    // Busy cursor during write
                //    using (new AddInStatusHelper(LightFieldApplication, ApplicationBusyStatus.Busy))
                //    {
                //        fm.Export(baseSettings_, itemsForExport);
                //    }
                //    ExportButton.IsEnabled = true;
                //}
            }
            finally
            {
                LightFieldApplication.UserInteractionManager.SuppressUserInteraction = false;
            }
        }
Ejemplo n.º 34
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     UpdateJiraProjectCache();
 }
Ejemplo n.º 35
0
 internal void UpdateAppSettings(IExportSettings newExportSettings)
 {
     exportSettings = newExportSettings;
 }
        /// <summary>
        /// Converts regular Commence value to its canonical representation.
        /// </summary>
        /// <remarks>Commence can return canonical values, but only from direct fields.
        /// This will convert all values to their canonical representation.
        /// </remarks>
        /// <param name="value">regular Commence value.</param>
        /// <param name="fieldType">Commence fieldtype.</param>
        /// <param name="settings">Settings.</param>
        /// <returns>string.</returns>
        internal static string ToCanonical(string value,
                                           Vovin.CmcLibNet.Database.CommenceFieldType fieldType,
                                           IExportSettings settings)
        {
            // Assumes we get a value from Commence, *not* some random string value.
            // The Commence value will be formatted according to system regional settings,
            // because that is the format Commence will display and return them.
            // We take advantage of that in TryParse to the proper .NET data type,
            // then we deconstruct that data type to return a string in canonical format.
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }
            string  retval     = value;
            bool    isCurrency = false;
            string  curSymbol  = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol;
            decimal number;

            switch (fieldType)
            {
            case CommenceFieldType.Sequence:
                if (decimal.TryParse(retval, out number))
                {
                    retval = Math.Truncate(number).ToString();
                }
                ;
                break;

            case CommenceFieldType.Calculation:
            case CommenceFieldType.Number:     // should return xxxx.yy
                // if Commence was set to "Display as currency" value will be preceded by the system currency symbol
                // This setting cannot be gotten from Commence, we have to resolve it at runtime.
                string numPart = retval;
                if (numPart.Contains(curSymbol))
                {
                    isCurrency = true;
                }
                numPart = RemoveCurrencySymbol(numPart);
                // try to cast
                if (decimal.TryParse(numPart, out number))
                {
                    long longPart = (long)Math.Truncate(number);     // may fail if number is bigger than long.
                    int  decPart;
                    decPart = (int)((Math.Abs(number) - Math.Abs(longPart)) * 100);
                    if (isCurrency && !settings.RemoveCurrencySymbol)
                    {
                        retval = longPart < 0
                                ? minusSymbol + CanonicalCurrencySymbol + Math.Abs(longPart).ToString() + '.' + decPart.ToString("D2")
                                : CanonicalCurrencySymbol + longPart.ToString() + '.' + decPart.ToString("D2");
                    }
                    else
                    {
                        retval = longPart.ToString() + '.' + decPart.ToString("D2");
                    }
                }
                break;

            case CommenceFieldType.Date:     // should return yyyymmdd
                DateTime date;
                if (DateTime.TryParse(value, out date))
                {
                    if (settings.ISO8601Format)
                    {
                        retval = ToIso8601(date, fieldType);
                    }
                    else
                    {
                        retval = date.Year.ToString("D4") + date.Month.ToString("D2") + date.Day.ToString("D2");
                    }
                }
                break;

            case CommenceFieldType.Time:     // should return hh:mm
                DateTime time;
                if (DateTime.TryParse(value, out time))
                {
                    if (settings.ISO8601Format)
                    {
                        retval = ToIso8601(time, fieldType);
                    }
                    else
                    {
                        retval = time.Hour.ToString("D2") + ':' + time.Minute.ToString("D2");
                    }
                }
                break;

            case CommenceFieldType.Checkbox:     // should return 'true' or 'false' (lowercase)
                // direct checkbox fields are returned as 'TRUE' or 'FALSE'
                if (value.Equals("TRUE") || value.Equals("FALSE"))
                {
                    retval = value.ToLower();     // all OK
                }
                else
                {
                    // related checkbox fields return 'Yes' or 'No'
                    retval = (value.ToLower() == "yes").ToString().ToLower();
                }
                break;
            }
            return(retval);
        }
Ejemplo n.º 37
0
 internal JiraTimerCollection(IExportSettings exportSettings, ITrackUsage trackUsage)
 {
     this.exportSettings = exportSettings;
     this.trackUsage = trackUsage;
     timerList = JiraTimerCollectionSerializer.DeSerialize();
 }
Ejemplo n.º 38
0
 internal DataSetSerializer(DataSet dataset, string fileName, IExportSettings settings)
 {
     _ds       = dataset;
     _settings = settings;
     _filename = fileName;
 }