public void ExportDataSources()
        {
            reader.GetDataSources("/SSRSMigrate_AW_Tests", GetDataSources_Reporter);

            foreach (DataSourceItem actualDataSourceItem in actualDataSourceItems)
            {
                string saveFilePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(actualDataSourceItem.Path, "json");

                ExportStatus actualStatus = dataSourceExporter.SaveItem(
                    actualDataSourceItem,
                    saveFilePath,
                    true);

                // Export was successful
                Assert.True(actualStatus.Success, string.Format("Success; {0}", actualDataSourceItem.Path));

                // Was exported to the expected location
                Assert.AreEqual(saveFilePath, actualStatus.ToPath, string.Format("ToPath; {0}", actualDataSourceItem.Path));

                // Was exported from the expected location
                Assert.AreEqual(actualDataSourceItem.Path, actualStatus.FromPath, string.Format("ToPath; {0}", actualDataSourceItem.Path));

                // The exported DataSourceItem exists on disk
                Assert.True(File.Exists(actualStatus.ToPath));
            }
        }
        public void ExportReports()
        {
            reader.GetReports("/SSRSMigrate_AW_Tests", GetReports_Reporter);

            foreach (ReportItem actualReportItem in actualReportItems)
            {
                string saveFilePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(actualReportItem.Path, "rdl");

                ExportStatus actualStatus = reportExporter.SaveItem(
                    actualReportItem,
                    saveFilePath,
                    true);

                // Export was successful
                Assert.True(actualStatus.Success, string.Format("Success; {0}", actualReportItem.Path));

                // Exported to the expected location
                Assert.AreEqual(saveFilePath, actualStatus.ToPath, string.Format("ToPath; {0}", actualReportItem.Path));

                // Was exported from the expected location
                Assert.AreEqual(actualReportItem.Path, actualStatus.FromPath, string.Format("ToPath; {0}", actualReportItem.Path));

                // The exported ReportItem exists on disk
                Assert.True(File.Exists(actualStatus.ToPath));
            }

            // The exported reports file matches the expected file
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[0], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Company Sales.rdl"));
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[1], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Sales Order Detail.rdl"));
            Assert.True(TesterUtility.CompareTextFiles(testReportFiles[2], outputPath + "\\SSRSMigrate_AW_Tests\\Reports\\Store Contacts.rdl"));
        }
Esempio n. 3
0
 private void WriteExportStatus(SPWorkItem workItem, ExportStatus status)
 {
     lock (_writeLock)
     {
         if (workItem != null)
         {
             using (SPSite site = new SPSite(workItem.SiteId))
             {
                 using (SPWeb web = site.OpenWeb(workItem.WebId))
                 {
                     try
                     {
                         SPList     exportsList = web.Lists[workItem.ParentId];
                         SPListItem exportItem  = exportsList.GetItemByUniqueId(workItem.ItemGuid);
                         if (exportItem != null)
                         {
                             exportItem["ExportStatus"] = status.ToString();
                             exportItem.SystemUpdate(true);
                         }
                     }
                     catch (Exception ex)
                     {
                         //failed to write ExportStatus
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
        private List <Task> StartExportTasks(
            ExportConfig config, ExportStatus status)
        {
            return(Enumerable
                   .Range(0, config.ExportTasks)
                   .Select(_ => Task.Factory.StartNew(() =>
            {
                while (
                    !status.IsEnumerationDone ||
                    !status.FileQueue.IsEmpty)
                {
                    if (!status.FileQueue.TryDequeue(out var file))
                    {
                        continue;
                    }

                    file.Extract(Path.Combine(config.ExportPath, file.Path));
                    status.ReportFileWritten(file.Size);
                    FileExported?.Invoke(
                        this,
                        new ExportedFileEventArgs(
                            status, file.Path, file.Size));
                }
            })).ToList());
        }
Esempio n. 5
0
 public void MarkExportCompleted()
 {
     if (Status == ExportStatus.Completed)
     {
         throw new CatalogExportAlreadyCompleted();
     }
     Status = ExportStatus.Completed;
 }
        public void SaveItem_FileExists_DontOverwrite()
        {
            ExportStatus actualStatus = exporter.SaveItem(reportItem, expectedReportItemFileName, false);

            Assert.False(actualStatus.Success);
            Assert.NotNull(actualStatus.Errors);
            Assert.AreEqual(actualStatus.Errors[0], string.Format("File '{0}' already exists.", expectedReportItemFileName));
        }
        public void SaveItem()
        {
            ExportStatus actualStatus = exporter.SaveItem(reportItem, expectedReportItemFileName, true);

            exportWriterMock.Verify(e => e.Save(expectedReportItemFileName, reportItem.Definition, true));

            Assert.True(actualStatus.Success);
            Assert.AreEqual(expectedReportItemFileName, actualStatus.ToPath);
            Assert.AreEqual(reportItem.Path, actualStatus.FromPath);
        }
        public void SaveItem()
        {
            ExportStatus actualStatus = exporter.SaveItem(dataSourceItem, expectedDataSourceItemFileName, true);

            exportWriterMock.Verify(e => e.Save(expectedDataSourceItemFileName, expectedDataSourceItemJson, true));

            Assert.True(actualStatus.Success);
            Assert.AreEqual(expectedDataSourceItemFileName, actualStatus.ToPath);
            Assert.AreEqual(dataSourceItem.Path, actualStatus.FromPath);
        }
Esempio n. 9
0
 internal ExportedFileEventArgs(ExportStatus status, string name, long size)
 {
     IsEnumerationDone      = status.IsEnumerationDone;
     TotalFilesWrittenCount = status.FilesWrittenCount;
     TotalFilesWrittenSize  = status.FilesWrittenSize;
     FileSize       = size;
     FileName       = name;
     TotalFileCount = status.TotalFileCount;
     TotalFileSize  = status.TotalFileSize;
 }
        public void ExportFolderItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(folderItems[0].Path);

            ExportStatus actualStatus = exporter.SaveItem(folderItems[0], filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.Null(actualStatus.Errors);
            Assert.True(Directory.Exists(actualStatus.ToPath));
        }
Esempio n. 11
0
        public void ExportReportItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(reportItem_CompanySales.Path, "rdl");

            ExportStatus actualStatus = exporter.SaveItem(reportItem_CompanySales, filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.True(File.Exists(actualStatus.ToPath));
            Assert.Null(actualStatus.Errors);
            Assert.True(TesterUtility.CompareTextFiles(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[0]), actualStatus.ToPath));
        }
Esempio n. 12
0
        public void ExportDataSourceItem()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(dataSourceItem.Path, "json");

            ExportStatus actualStatus = exporter.SaveItem(dataSourceItem, filePath);

            Assert.True(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.Null(actualStatus.Errors);
            Assert.True(File.Exists(filePath));
            Assert.AreEqual(expectedDataSourceJson, File.ReadAllText(filePath));
        }
        public void ExportFolderItem_FileDontOverwrite()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(folderItems[0].Path);

            // Create dummy directory
            Directory.CreateDirectory(filePath);

            ExportStatus actualStatus = exporter.SaveItem(folderItems[0], filePath, false);

            Assert.False(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.NotNull(actualStatus.Errors);
            Assert.True(actualStatus.Errors.Any(e => e.Contains(string.Format("Directory '{0}' already exists.", filePath))));
        }
Esempio n. 14
0
        public void WithErrors()
        {
            string expectedToPath   = "C:\\temp\\SSRSMigrate_AW_Tests\\Reports";
            string expectedFromPath = "/SSRSMigrate_AW_Tests/Reports";
            bool   expectedSuccess  = false;

            string[] expectedErrors = new string[] { "Permission denied." };

            ExportStatus actualStatus = new ExportStatus(expectedToPath, expectedFromPath, expectedErrors, expectedSuccess);

            Assert.AreEqual(expectedToPath, actualStatus.ToPath);
            Assert.AreEqual(expectedFromPath, actualStatus.FromPath);
            Assert.AreEqual(expectedErrors, actualStatus.Errors);
            Assert.AreEqual(expectedSuccess, actualStatus.Success);
        }
Esempio n. 15
0
        public void ExportReportItem_FileDontOverwrite()
        {
            string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(reportItem_CompanySales.Path, "rdl");

            // Create dummy file, so the output file already exists, causing the SaveItem to fail
            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            File.WriteAllText(filePath, "DUMMY FILE");

            ExportStatus actualStatus = exporter.SaveItem(reportItem_CompanySales, filePath, false);

            Assert.False(actualStatus.Success);
            Assert.AreEqual(filePath, actualStatus.ToPath);
            Assert.NotNull(actualStatus.Errors);
            Assert.True(actualStatus.Errors.Any(e => e.Contains(string.Format("File '{0}' already exists.", filePath))));
        }
Esempio n. 16
0
        internal static string ToSerializedValue(this ExportStatus value)
        {
            switch (value)
            {
            case ExportStatus.InProgress:
                return("InProgress");

            case ExportStatus.Completed:
                return("Completed");

            case ExportStatus.Failed:
                return("Failed");
            }
            return(null);
        }
Esempio n. 17
0
        public void EmptyFromPath()
        {
            string expectedToPath  = "C:\\temp\\SSRSMigrate_Tests\\Reports";
            bool   expectedSuccess = true;

            string[] expectedErrors = null;

            ArgumentException ex = Assert.Throws <ArgumentException>(
                delegate
            {
                ExportStatus actualStatus = new ExportStatus(expectedToPath, "", expectedErrors, expectedSuccess);
            });

            Assert.That(ex.Message, Is.EqualTo("pathFrom"));
        }
Esempio n. 18
0
        public void NullToPath()
        {
            string expectedFromPath = "/SSRSMigrate_AW_Tests/Reports";
            bool   expectedSuccess  = true;

            string[] expectedErrors = null;

            ArgumentException ex = Assert.Throws <ArgumentException>(
                delegate
            {
                ExportStatus actualStatus = new ExportStatus(null, expectedFromPath, expectedErrors, expectedSuccess);
            });

            Assert.That(ex.Message, Is.EqualTo("pathTo"));
        }
Esempio n. 19
0
        public void Succeed()
        {
            string expectedToPath   = "C:\\temp\\SSRSMigrate_AW_Tests\\Reports";
            string expectedFromPath = "/SSRSMigrate_AW_Tests/Reports";
            bool   expectedSuccess  = true;

            string[] expectedErrors = null;

            ExportStatus actualStatus = new ExportStatus(expectedToPath, expectedFromPath, expectedErrors, expectedSuccess);

            Assert.AreEqual(expectedToPath, actualStatus.ToPath);
            Assert.AreEqual(expectedFromPath, actualStatus.FromPath);
            Assert.AreEqual(expectedErrors, actualStatus.Errors);
            Assert.AreEqual(expectedSuccess, actualStatus.Success);
        }
Esempio n. 20
0
        private bool ChangeStatus(int batchNo, ExportStatus newStatus)
        {
            ExportHeader exportHeader;

            if (Read(out exportHeader, batchNo))
            {
                var before = exportHeader.ExportStatus;
                exportHeader.ExportStatus = newStatus;
                var msg = String.Format("{0:yyyy-MM-dd HH:mm}, {1:G} -> {2:G}", SystemDateTime.Now, before, newStatus);
                exportHeader.HistoryLog = "; ".Concatenate(exportHeader.HistoryLog, msg);
                ContextSharedPickup.SaveChanges();
                return(true);
            }

            return(false);
        }
        public ExportCompletedEventArgs(string fileLocation, object userState, string mapname, ExportStatus? status = null, string errorMessage = null)
        {
            UserState = userState;
            FileLocation = fileLocation;
            MapName = mapname;

            if (status.HasValue)
            {
                Status = status.Value;
            }
            else
            {
                Status = ExportStatus.Completed;
            }
            ErrorMessage = errorMessage;
        }
Esempio n. 22
0
        public void ExportReportItems()
        {
            for (int i = 0; i < reportItems.Count(); i++)
            {
                ReportItem reportItem = reportItems[i];

                string filePath = outputPath + SSRSUtil.GetServerPathToPhysicalPath(reportItem.Path, "rdl");

                ExportStatus actualStatus = exporter.SaveItem(reportItem, filePath);

                Assert.True(actualStatus.Success, "Success");
                Assert.AreEqual(filePath, actualStatus.ToPath, "ToPath");
                Assert.True(File.Exists(actualStatus.ToPath), " ToPath.Exists");
                Assert.Null(actualStatus.Errors);
                Assert.True(TesterUtility.CompareTextFiles(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[i]), actualStatus.ToPath), "CompareTextFiles");
            }
        }
Esempio n. 23
0
        private void bw_ExportItems_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.progressBar.Value       = e.ProgressPercentage;
            this.progressBar.Maximum     = 100;
            this.progressBar.ToolTipText = string.Format("{0} %", e.ProgressPercentage);

            if (e.UserState != null)
            {
                ExportStatus exportStatus = (ExportStatus)e.UserState;

                if (exportStatus.Success)
                {
                    string msg = string.Format("Saved item from '{0}' to '{1}'.",
                                               exportStatus.FromPath,
                                               exportStatus.ToPath);

                    this.mDebugForm.LogMessage(msg);
                    this.mLogger.Debug("ExportItemsProgressChanged - {0}", msg);

                    this.lblStatus.Text = msg;

                    this.mSummaryForm.IncrementSuccessfulItemsCount();
                }
                else
                {
                    string msg = string.Format("Failed to export item from '{0}' to '{1}': {2}",
                                               exportStatus.FromPath,
                                               exportStatus.ToPath,
                                               string.Join(",", exportStatus.Errors));

                    this.mDebugForm.LogMessage(msg, true);
                    this.mLogger.Error(msg);
                    this.lblStatus.Text = string.Format("Failed '{0}': {1}",
                                                        exportStatus.ToPath,
                                                        string.Join(",", exportStatus.Errors));

                    this.mSummaryForm.AddFailedItem(exportStatus.FromPath, string.Join(",", exportStatus.Errors));
                }

                this.mSummaryForm.IncrementTotalItemsCount();
            }
            else
            {
                this.mLogger.Warn("ExportItemsProgressChanged - ExportStatus is NULL.");
            }
        }
Esempio n. 24
0
        private static List <Task> StartEnumerationTasks(
            ExportConfig config, ExportStatus status)
        {
            return(Enumerable
                   .Range(0, config.EnumerationTasks)
                   .Select(_ => Task.Factory.StartNew(() =>
            {
                while (status.DirQueue.TryDequeue(out var dir))
                {
                    if (!config.Shallow)
                    {
                        FillQueue(
                            status.DirQueue,
                            dir.Directories.Values);
                    }

                    status.ReportFilesDiscovered(dir.Files.Values);
                    FillQueue(status.FileQueue, dir.Files.Values);
                }
                status.IsEnumerationDone = true;
            })).ToList());
        }
Esempio n. 25
0
        public async Task Export(IEnumerable <IDirectory> ggpkDirs, ExportConfig config)
        {
            var status = new ExportStatus();

            if (!config.Shallow)
            {
                FillQueue(status.DirQueue, ggpkDirs);
            }
            else
            {
                foreach (var dir in ggpkDirs)
                {
                    FillQueue(
                        status.FileQueue,
                        dir.Files.Values);
                }
            }

            await Task.WhenAll(Enumerable.Union(
                                   StartEnumerationTasks(config, status),
                                   StartExportTasks(config, status))).ConfigureAwait(false);

            await Task.Delay(50);
        }
        private void WriteExportStatus(SPWorkItem workItem, ExportStatus status)
        {
            lock (_writeLock)
            {
                if (workItem != null)
                {
                    using (SPSite site = new SPSite(workItem.SiteId))
                    {
                        using (SPWeb web = site.OpenWeb(workItem.WebId))
                        {
                            try
                            {
                                SPList exportsList = web.Lists[workItem.ParentId];
                                SPListItem exportItem = exportsList.GetItemByUniqueId(workItem.ItemGuid);
                                if (exportItem != null)
                                {

                                    exportItem["ExportStatus"] = status.ToString();
                                    exportItem.SystemUpdate(true);

                                }
                            }
                            catch (Exception ex) 
                            { 
                                //failed to write ExportStatus
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Deletes an ExportJob if it's in the Scheduled, Completed, or Error ExportStates.
        /// </summary>
        /// <param name="job">The ExportJob to delete</param>
        /// <returns>The ExportJob that was deleted</returns>
        public ExportJobResponse DeleteExportJob(ExportJob job)
        {
            ExportJobResponse response = new ExportJobResponse();

            try
            {
                Guid webID  = SPContext.Current.Web.ID;
                Guid siteID = SPContext.Current.Site.ID;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPList exportsList = null;
                    using (SPSite site = new SPSite(siteID))
                    {
                        using (SPWeb web = site.OpenWeb(webID))
                        {
                            if (web != null && site != null)
                            {
                                exportsList = web.TryGetList(web.GetServerRelativeListUrlPrefix() + "GlymaExports");
                                if (exportsList != null)
                                {
                                    SPQuery query = new SPQuery();
                                    query.Query   = "<Where>" +
                                                    "<Eq><FieldRef Name='Title' /><Value Type='Text'>" + job.Id.ToString() + "</Value></Eq>" +
                                                    "</Where>";
                                    SPListItemCollection exports = exportsList.GetItems(query);
                                    // There can only be one ExportJob with the job ID (unique values enforced in SP list for Title column)
                                    if (exports.Count > 0)
                                    {
                                        SPListItem exportItem = exports[0];
                                        if (exportItem != null)
                                        {
                                            string exportStatusStr    = exportItem["ExportStatus"] as string;
                                            ExportStatus exportStatus = (ExportStatus)Enum.Parse(typeof(ExportStatus), exportStatusStr, true);

                                            if (exportStatus == ExportStatus.Scheduled)
                                            {
                                                SPWorkItemCollection workItemsCollection = new SPWorkItemCollection(site, GlymaExportWorkItemTimerJob.WorkItemTypeId);
                                                uint colCount, rowCount = 0;
                                                object workItems        = null;
                                                site.GetWorkItems(workItemsCollection, out colCount, out rowCount, out workItems); //gets all work items for this site of the type GlymaExportWorkItemTimerJob
                                                if (workItemsCollection.Count > 0)
                                                {
                                                    // Delete the work item that this export job created
                                                    SPWorkItemCollection subCollection = workItemsCollection.SubCollection(site, web, 0, (uint)workItemsCollection.Count);
                                                    subCollection.DeleteWorkItem(job.Id);
                                                }
                                            }

                                            if (exportStatus == ExportStatus.Scheduled || exportStatus == ExportStatus.Completed || exportStatus == ExportStatus.Error)
                                            {
                                                exportItem.Delete(); //delete the item after it has been cancelled
                                            }
                                            else if (exportStatus == ExportStatus.Processing)
                                            {
                                                throw new Exception("The export job is currently processing and cannot be deleted.");
                                            }
                                        }
                                        response.ExportJob = job;
                                    }
                                }
                                else
                                {
                                    throw new Exception("Failed to find the Glyma Exports list.");
                                }
                            }
                            else
                            {
                                throw new Exception("The SPSite and/or the SPWeb were null.");
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                ExportError error = new ExportError()
                {
                    ErrorMessage = "Failed to cancel the Glyma map export job."
                };
                throw new FaultException <ExportError>(error, ex.ToString());
            }

            return(response);
        }
 /// <summary>
 /// Initializes a new instance of the ExportStatusResult class.
 /// </summary>
 /// <param name="exportId">The unique export identifier.</param>
 /// <param name="status">Status of the export. Possible values include:
 /// 'InProgress', 'Completed', 'Failed'</param>
 public ExportStatusResult(string exportId, ExportStatus status)
 {
     ExportId = exportId;
     Status   = status;
     CustomInit();
 }
        /// <summary></summary>
        protected override void AddNextNodeToCycle(IFocusCyclableNodeState state)
        {
            IFocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList;
            INode           ParentNode = state.ParentState.Node;
            IFocusNodeIndex NodeIndex  = state.ParentIndex as IFocusNodeIndex;

            IDocument    Documentation    = null;
            IIdentifier  ExportIdentifier = null;
            ExportStatus Export           = ExportStatus.Exported;
            IName        EntityName       = null;
            IObjectType  EntityType       = null;
            IBlockList <IAssertion, Assertion> EnsureBlocks = null;
            IExpression ConstantValue = null;
            IBlockList <ICommandOverload, CommandOverload> CommandOverloadBlocks = null;
            OnceChoice Once = OnceChoice.Normal;
            IBlockList <IQueryOverload, QueryOverload> QueryOverloadBlocks = null;
            UtilityType PropertyKind = UtilityType.ReadWrite;
            IBlockList <IIdentifier, Identifier> ModifiedQueryBlocks = null;
            IOptionalReference <IBody>           GetterBody          = null;
            IOptionalReference <IBody>           SetterBody          = null;
            IBlockList <IEntityDeclaration, EntityDeclaration> IndexParameterBlocks = null;
            ParameterEndStatus ParameterEnd = ParameterEndStatus.Closed;

            List <Type> FeatureTypeList = new List <Type>()
            {
                typeof(AttributeFeature), typeof(ConstantFeature), typeof(CreationFeature), typeof(FunctionFeature), typeof(ProcedureFeature), typeof(PropertyFeature), typeof(IndexerFeature)
            };

            foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList)
            {
                IFeature Feature = Index.Node as IFeature;
                Debug.Assert(Feature != null);

                if (FeatureTypeList.Contains(Feature.GetType()))
                {
                    FeatureTypeList.Remove(Feature.GetType());
                }

                switch (Feature)
                {
                case IAttributeFeature AsAttribute:
                    Documentation    = AsAttribute.Documentation;
                    ExportIdentifier = AsAttribute.ExportIdentifier;
                    Export           = AsAttribute.Export;
                    EntityName       = AsAttribute.EntityName;
                    EntityType       = AsAttribute.EntityType;
                    EnsureBlocks     = AsAttribute.EnsureBlocks;
                    break;

                case IConstantFeature AsConstant:
                    Documentation    = AsConstant.Documentation;
                    ExportIdentifier = AsConstant.ExportIdentifier;
                    Export           = AsConstant.Export;
                    EntityName       = AsConstant.EntityName;
                    EntityType       = AsConstant.EntityType;
                    ConstantValue    = AsConstant.ConstantValue;
                    break;

                case ICreationFeature AsCreation:
                    Documentation         = AsCreation.Documentation;
                    ExportIdentifier      = AsCreation.ExportIdentifier;
                    Export                = AsCreation.Export;
                    EntityName            = AsCreation.EntityName;
                    CommandOverloadBlocks = AsCreation.OverloadBlocks;
                    break;

                case IFunctionFeature AsFunction:
                    Documentation       = AsFunction.Documentation;
                    ExportIdentifier    = AsFunction.ExportIdentifier;
                    Export              = AsFunction.Export;
                    EntityName          = AsFunction.EntityName;
                    Once                = AsFunction.Once;
                    QueryOverloadBlocks = AsFunction.OverloadBlocks;
                    break;

                case IProcedureFeature AsProcedure:
                    Documentation         = AsProcedure.Documentation;
                    ExportIdentifier      = AsProcedure.ExportIdentifier;
                    Export                = AsProcedure.Export;
                    EntityName            = AsProcedure.EntityName;
                    CommandOverloadBlocks = AsProcedure.OverloadBlocks;
                    break;

                case IPropertyFeature AsProperty:
                    Documentation       = AsProperty.Documentation;
                    ExportIdentifier    = AsProperty.ExportIdentifier;
                    Export              = AsProperty.Export;
                    EntityName          = AsProperty.EntityName;
                    EntityType          = AsProperty.EntityType;
                    PropertyKind        = AsProperty.PropertyKind;
                    ModifiedQueryBlocks = AsProperty.ModifiedQueryBlocks;
                    GetterBody          = AsProperty.GetterBody;
                    SetterBody          = AsProperty.SetterBody;
                    break;

                case IIndexerFeature AsIndexer:
                    Documentation        = AsIndexer.Documentation;
                    ExportIdentifier     = AsIndexer.ExportIdentifier;
                    Export               = AsIndexer.Export;
                    EntityType           = AsIndexer.EntityType;
                    IndexParameterBlocks = AsIndexer.IndexParameterBlocks;
                    ParameterEnd         = AsIndexer.ParameterEnd;
                    ModifiedQueryBlocks  = AsIndexer.ModifiedQueryBlocks;
                    GetterBody           = AsIndexer.GetterBody;
                    SetterBody           = AsIndexer.SetterBody;
                    break;
                }

                Debug.Assert(CommandOverloadBlocks == null || CommandOverloadBlocks.NodeBlockList.Count > 0);
                Debug.Assert(QueryOverloadBlocks == null || QueryOverloadBlocks.NodeBlockList.Count > 0);
                Debug.Assert(IndexParameterBlocks == null || IndexParameterBlocks.NodeBlockList.Count > 0);
            }

            // If the list is full, no need to add more nodes to the cycle.
            if (FeatureTypeList.Count > 0)
            {
                Type NodeType = FeatureTypeList[0];

                INode NewFeature = NodeHelper.CreateInitializedFeature(NodeType, Documentation, ExportIdentifier, Export, EntityName, EntityType, EnsureBlocks, ConstantValue, CommandOverloadBlocks, Once, QueryOverloadBlocks, PropertyKind, ModifiedQueryBlocks, GetterBody, SetterBody, IndexParameterBlocks, ParameterEnd);

                IFocusInsertionChildNodeIndex InsertionIndex = (IFocusInsertionChildNodeIndex)((IFocusBrowsingInsertableIndex)NodeIndex).ToInsertionIndex(ParentNode, NewFeature);
                CycleIndexList.Add(InsertionIndex);
            }
        }
Esempio n. 30
0
 /// <summary>
 /// Sends the status.
 /// </summary>
 /// <param name="exportStatus">
 /// Export status class.
 /// </param>
 public static void SendExportStatus(ExportStatus exportStatus)
 {
     if (exportStatus != null)
         ServerStatusHub.NotifyExportStatus(exportStatus);
 }
Esempio n. 31
0
        /// <summary>
        /// درج مقادیر اولیه در دیتابیس به هنگام ساخت دیتابیس
        /// </summary>
        /// <param name="context">شی دیتابیس اصلی برنامه</param>
        protected override void Seed(AsefianContext context)
        {
            foreach (var item in Language.GetList())
            {
                context.Language.Add(item);
            }
            #region Account
            foreach (var item in UserType.GetList())
            {
                context.UserType.Add(item);
            }
            foreach (var item in BalanceType.GetList())
            {
                context.BalanceType.Add(item);
            }
            foreach (var item in Browser.GetList())
            {
                context.Browser.Add(item);
            }
            foreach (var item in DeviceType.GetList())
            {
                context.DeviceType.Add(item);
            }
            foreach (var item in GroupStatus.GetList())
            {
                context.GroupStatus.Add(item);
            }
            foreach (var item in NotificationStatus.GetList())
            {
                context.NotificationStatus.Add(item);
            }
            foreach (var item in NotificationType.GetList())
            {
                context.NotificationType.Add(item);
            }
            foreach (var item in Account.Enum.OperatingSystem.GetList())
            {
                context.OperatingSystem.Add(item);
            }
            foreach (var item in Sex.GetList())
            {
                context.Sex.Add(item);
            }
            foreach (var item in TokenType.GetList())
            {
                context.TokenType.Add(item);
            }
            foreach (var item in UserAddressStatus.GetList())
            {
                context.UserAddressStatus.Add(item);
            }
            foreach (var item in UserFavoriteFolderStatus.GetList())
            {
                context.UserFavoriteFolderStatus.Add(item);
            }
            foreach (var item in UserFavoriteStatus.GetList())
            {
                context.UserFavoriteStatus.Add(item);
            }
            foreach (var item in UserStatus.GetList())
            {
                context.UserStatus.Add(item);
            }
            #endregion

            #region Blog

            foreach (var item in ArticleFileStatus.GetList())
            {
                context.ArticleFileStatus.Add(item);
            }

            foreach (var item in ArticleStatus.GetList())
            {
                context.ArticleStatus.Add(item);
            }

            foreach (var item in NewsStatus.GetList())
            {
                context.NewsStatus.Add(item);
            }
            #endregion

            #region Core
            foreach (var item in BranchStatus.GetList())
            {
                context.BranchStatus.Add(item);
            }
            foreach (var item in LocationType.GetList())
            {
                context.LocationType.Add(item);
            }
            foreach (var item in SliderContentStatus.GetList())
            {
                context.SliderContentStatus.Add(item);
            }
            foreach (var item in SliderStatus.GetList())
            {
                context.SliderStatus.Add(item);
            }
            foreach (var item in SliderType.GetList())
            {
                context.SliderType.Add(item);
            }
            #endregion

            #region Data
            foreach (var item in ExportStatus.GetList())
            {
                context.ExportStatus.Add(item);
            }
            foreach (var item in ContactUsStatus.GetList())
            {
                context.ContactUsStatus.Add(item);
            }
            foreach (var item in SpecialProjectStatus.GetList())
            {
                context.SpecialProjectStatus.Add(item);
            }
            foreach (var item in SpecialProjectFileStatus.GetList())
            {
                context.SpecialProjectFileStatus.Add(item);
            }
            foreach (var item in BrandStatus.GetList())
            {
                context.BrandStatus.Add(item);
            }
            foreach (var item in CategoryFeatureStatus.GetList())
            {
                context.CategoryFeatureStatus.Add(item);
            }
            foreach (var item in CategoryFeatureType.GetList())
            {
                context.CategoryFeatureType.Add(item);
            }
            foreach (var item in CategoryStatus.GetList())
            {
                context.CategoryStatus.Add(item);
            }
            foreach (var item in CategoryType.GetList())
            {
                context.CategoryType.Add(item);
            }
            foreach (var item in DownloadCenterStatus.GetList())
            {
                context.DownloadCenterStatus.Add(item);
            }
            foreach (var item in ProductFileStatus.GetList())
            {
                context.ProductFileStatus.Add(item);
            }
            foreach (var item in ProductFileType.GetList())
            {
                context.ProductFileType.Add(item);
            }
            foreach (var item in ProductFilterStatus.GetList())
            {
                context.ProductFilterStatus.Add(item);
            }
            foreach (var item in ProductFilterType.GetList())
            {
                context.ProductFilterType.Add(item);
            }
            foreach (var item in ProductFilterValueStatus.GetList())
            {
                context.ProductFilterValueStatus.Add(item);
            }
            foreach (var item in ProductStatus.GetList())
            {
                context.ProductStatus.Add(item);
            }
            foreach (var item in ServiceStatus.GetList())
            {
                context.ServiceStatus.Add(item);
            }
            #endregion

            #region Financial
            foreach (var item in CouponStatus.GetList())
            {
                context.CouponStatus.Add(item);
            }
            foreach (var item in CouponType.GetList())
            {
                context.CouponType.Add(item);
            }
            foreach (var item in DeliveryType.GetList())
            {
                context.DeliveryType.Add(item);
            }
            foreach (var item in InquiryStatus.GetList())
            {
                context.InquiryStatus.Add(item);
            }
            foreach (var item in InvoiceDetailStatus.GetList())
            {
                context.InvoiceDetailStatus.Add(item);
            }
            foreach (var item in InvoiceStatus.GetList())
            {
                context.InvoiceStatus.Add(item);
            }
            foreach (var item in PaymentType.GetList())
            {
                context.PaymentType.Add(item);
            }
            #endregion

            #region Support
            foreach (var item in FaqCategoryStatus.GetList())
            {
                context.FaqCategoryStatus.Add(item);
            }
            foreach (var item in FaqStatus.GetList())
            {
                context.FaqStatus.Add(item);
            }
            foreach (var item in MessageBoxStatus.GetList())
            {
                context.MessageBoxStatus.Add(item);
            }
            foreach (var item in NewsLetterStatus.GetList())
            {
                context.NewsLetterStatus.Add(item);
            }
            foreach (var item in TicketMessageType.GetList())
            {
                context.TicketMessageType.Add(item);
            }
            foreach (var item in TicketPriority.GetList())
            {
                context.TicketPriority.Add(item);
            }
            foreach (var item in TicketStatus.GetList())
            {
                context.TicketStatus.Add(item);
            }
            foreach (var item in MessageType.GetList())
            {
                context.MessageType.Add(item);
            }
            #endregion

            var admin = new User()
            {
                FirstName         = "مدیر",
                LastName          = "سیستم",
                MobileNumber      = "09122424519",
                MobileNumberValid = true,
                Email             = "*****@*****.**",
                EmailValid        = true,
                SexId             = Sex.Male.Id,
                TypeId            = UserType.Insider.Id,
                Password          = PasswordUtility.Encrypt("alialiali"),
                StatusId          = UserStatus.Active.Id,
                Permission        = 1,
                CreateDate        = DateTime.Now,
                ModifyDate        = DateTime.Now,
                CreateIp          = "::1",
                ModifyIp          = "::1"
            };
            context.User.Add(admin);
        }
Esempio n. 32
0
        private void ExportItemsWorker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker     = sender as BackgroundWorker;
            string           exportPath = (string)e.Argument;

            // Stopwatch to track how long the export takes
            Stopwatch watch = new Stopwatch();

            // Start stopwatch to get how long it takes to get the total number of checked items
            watch.Start();

            IEnumerable <ListViewItem> lvItems = GetListViewItems(this.lstSrcReports).Cast <ListViewItem>();

            // Get total count of items in ListView that are checked
            int totalItems                 = lvItems.Where(lv => lv.Checked == true).Count();
            int progressCounter            = 0;
            int reportsExportedCounter     = 0;
            int reportsTotalCount          = 0;
            int foldersExportedCounter     = 0;
            int foldersTotalCount          = 0;
            int dataSourcesExportedCounter = 0;
            int dataSourcesTotalCount      = 0;

            // Stop stopwatch after getting the total number of checked items, and log how long it took
            watch.Stop();
            this.mLogger.Debug("ExportItemsWorker - Took {0} seconds to get checked ListView items", watch.Elapsed.TotalSeconds);

            // Start stopwatch to get how long it takes to export everything
            watch.Start();

            // Export folders
            // Get path of ListView items in the folder group that are checked.
            var folderPaths = from lv in lvItems
                              where lv.Group.Name == "foldersGroup" &&
                              lv.Checked == true
                              select(string) lv.Tag;

            foldersTotalCount = folderPaths.Count();

            this.mLogger.Debug("ExportItemsWorker - {0} folders in Listview", foldersTotalCount);

            foreach (string folderPath in folderPaths)
            {
                ExportStatus status = null;

                if (!string.IsNullOrEmpty(folderPath))
                {
                    FolderItem folderItem = this.mReportServerReader.GetFolder(folderPath);

                    if (folderItem != null)
                    {
                        // Path to where to export folder on disk
                        string saveFilePath = exportPath + SSRSUtil.GetServerPathToPhysicalPath(folderPath);

                        this.mLogger.Debug("ExportItemsWorker - Got save file path of '{0}' for folder item path '{1}'", saveFilePath, folderPath);

                        status = this.mFolderExporter.SaveItem(folderItem,
                                                               saveFilePath,
                                                               true);

                        this.mLogger.Debug("ExportItemsWorker - FolderItem.Success = {0}; FromPath = {1}; ToPath = {2}",
                                           status.Success,
                                           status.FromPath,
                                           status.ToPath);

                        // If the save to the temporary path was successful, add folder to the ZipBundler
                        if (status.Success)
                        {
                            this.mZipBundler.AddItem(
                                "Folders",
                                status.ToPath,
                                status.FromPath,
                                true);

                            ++foldersExportedCounter;
                        }
                    }
                    else
                    {
                        this.mLogger.Warn("ExportItemsWorker - FolderItem for path '{0}' returned NULL.", folderPath);
                    }
                }

                // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader.
                // This will keep the progress bar value from suddenly jumping up several values.
                if (worker != null)
                {
                    worker.ReportProgress(((++progressCounter * 100) / totalItems), status);
                }
                else
                {
                    this.mLogger.Warn("ExportItemsWorker - worker is NULL.");
                }
            }

            // Export data sources
            var dataSourcePaths = from lv in lvItems
                                  where lv.Group.Name == "dataSourcesGroup" &&
                                  lv.Checked == true
                                  select(string) lv.Tag;

            dataSourcesTotalCount = dataSourcePaths.Count();

            this.mLogger.Debug("ExportItemsWorker - {0} data sources in Listview", dataSourcesTotalCount);

            foreach (string dataSourcePath in dataSourcePaths)
            {
                ExportStatus status = null;

                if (!string.IsNullOrEmpty(dataSourcePath))
                {
                    DataSourceItem dataSourceItem = this.mReportServerReader.GetDataSource(dataSourcePath);

                    if (dataSourceItem != null)
                    {
                        // Path to where to export data source on disk
                        string saveFilePath = exportPath + SSRSUtil.GetServerPathToPhysicalPath(dataSourcePath, "json");

                        this.mLogger.Debug("ExportItemsWorker - Got save file path of '{0}' for data source item path '{1}'", saveFilePath, dataSourcePath);

                        status = this.mDataSourceExporter.SaveItem(dataSourceItem,
                                                                   saveFilePath,
                                                                   true);

                        this.mLogger.Debug("ExportItemsWorker - DataSourceItem.Success = {0}; FromPath = {1}; ToPath = {2}",
                                           status.Success,
                                           status.FromPath,
                                           status.ToPath);

                        // If the save to the temporary path was successful, add file to the ZipBundler
                        if (status.Success)
                        {
                            this.mZipBundler.AddItem(
                                "DataSources",
                                status.ToPath,
                                status.FromPath,
                                false);

                            ++dataSourcesExportedCounter;
                        }
                    }
                    else
                    {
                        this.mLogger.Warn("ExportItemsWorker - DataSourceItem for path '{0}' returned NULL.", dataSourcePath);
                    }
                }

                // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader.
                // This will keep the progress bar value from suddenly jumping up several values.
                if (worker != null)
                {
                    worker.ReportProgress(((++progressCounter * 100) / totalItems), status);
                }
                else
                {
                    this.mLogger.Warn("ExportItemsWorker - worker is NULL.");
                }
            }

            // Export reports
            var reportPaths = from lv in lvItems
                              where lv.Group.Name == "reportsGroup" &&
                              lv.Checked == true
                              select(string) lv.Tag;

            reportsTotalCount = reportPaths.Count();

            this.mLogger.Debug("ExportItemsWorker - {0} reports in Listview", reportsTotalCount);

            foreach (string reportPath in reportPaths)
            {
                ExportStatus status = null;

                if (!string.IsNullOrEmpty(reportPath))
                {
                    ReportItem reportItem = this.mReportServerReader.GetReport(reportPath);

                    if (reportItem != null)
                    {
                        // Path to where to export report on disk
                        string saveFilePath = exportPath + SSRSUtil.GetServerPathToPhysicalPath(reportPath, "rdl");

                        this.mLogger.Debug("ExportItemsWorker - Got save file path of '{0}' for report item path '{1}'", saveFilePath, reportPath);

                        status = this.mReportExporter.SaveItem(reportItem,
                                                               saveFilePath,
                                                               true);

                        this.mLogger.Debug("ExportItemsWorker - ReportItem.Success = {0}; FromPath = {1}; ToPath = {2}",
                                           status.Success,
                                           status.FromPath,
                                           status.ToPath);

                        // If the save to the temporary path was successful, add file to the ZipBundler
                        if (status.Success)
                        {
                            this.mZipBundler.AddItem(
                                "Reports",
                                status.ToPath,
                                status.FromPath,
                                false);

                            ++reportsExportedCounter;
                        }
                    }
                    else
                    {
                        this.mLogger.Warn("ExportItemsWorker - ReportItem for path '{0}' returned NULL.", reportPath);
                    }
                }

                // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader.
                // This will keep the progress bar value from suddenly jumping up several values.
                if (worker != null)
                {
                    worker.ReportProgress(((++progressCounter * 100) / totalItems), status);
                }
                else
                {
                    this.mLogger.Warn("ExportItemsWorker - worker is NULL.");
                }
            }

            // Stop stopwatch and get how long it took for the export to complete successfully
            watch.Stop();
            double averageItem = watch.Elapsed.TotalSeconds / progressCounter;

            string result = string.Format("{0}/{1} folders, {2}/{3} data sources, {4}/{5} reports exported in {6}h {7}m {8}s (@ {9:0.00} items/s)",
                                          foldersExportedCounter,
                                          foldersTotalCount,
                                          dataSourcesExportedCounter,
                                          dataSourcesTotalCount,
                                          reportsExportedCounter,
                                          reportsTotalCount,
                                          watch.Elapsed.Hours,
                                          watch.Elapsed.Minutes,
                                          watch.Elapsed.Seconds,
                                          averageItem);

            this.mLogger.Info("ExportItemsWorker - {0}", result);

            e.Result = result;
        }