Ejemplo n.º 1
0
        public ActionResult Import(HttpPostedFileBase file)
        {
            ViewBag.FileFormat = "Organization_1_UniqueIdentifier,Organization_1_UniqueidentifierColumn,Organization_1_Name,Id,Organization_2Id,Organization_2_UniqueIdentifier,Organization_2_UniqueidentifierColumn,Organization_2_Name,ExternalParentId,Name,Description,OrganizationId";
            if (file != null && file.ContentLength > 0 && !string.IsNullOrWhiteSpace(file.FileName))
            {
                log.Info(string.Format("{0}: Import", Framework.LoggingOptions.UI_Process_Started.ToString()));

                Framework.DataStreamServiceResult dataStreamServiceResult = new Framework.DataStreamServiceResult(file.FileName, file.ContentType, file.ContentLength, file.InputStream);
                dataStreamServiceResult.TempFilePath = Framework.Web.WebFormApplicationApplicationVariables.FileStorageRootFolder;
                MSBuildExtensionPack.CommonBLL.SolutionDataStreamService.Default   dataStreamServiceProvider = new MSBuildExtensionPack.CommonBLL.SolutionDataStreamService.Default();
                MSBuildExtensionPack.DataSourceEntities.Solution.DefaultCollection collection = dataStreamServiceProvider.GetCollectionFromStream(dataStreamServiceResult);

                if (collection != null)
                {
                    MSBuildExtensionPack.DataSourceEntities.SolutionCollection resultCollection = new MSBuildExtensionPack.DataSourceEntities.SolutionCollection();
                    MSBuildExtensionPack.EntityContracts.ISolutionHelper.CopyCollection <MSBuildExtensionPack.DataSourceEntities.Solution.DefaultCollection, MSBuildExtensionPack.DataSourceEntities.SolutionCollection, MSBuildExtensionPack.DataSourceEntities.Solution.Default, MSBuildExtensionPack.DataSourceEntities.Solution>(collection, resultCollection);
                    var result = MSBuildExtensionPack.CommonBLLIoC.IoCSolution.BatchInsert(resultCollection);
                    ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_Success;
                }
                else
                {
                    ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_NoRecordInSourceFile;
                }

                log.Info(string.Format("{0}: Import", Framework.LoggingOptions.UI_Process_Ended.ToString()));

                return(View());
            }
            else
            {
                ViewBag.Message = "";
                return(View());
            }
        }
 /// <summary>
 /// Validates the value before save to database.
 /// </summary>
 /// <param name="input">The input.</param>
 public static void ValidateValueBeforeSaveToDatabase(MSBuildExtensionPack.DataSourceEntities.SolutionCollection input)
 {
     for (int i = 0; i < input.Count; i++)
     {
         MSBuildExtensionPack.DataSourceEntities.Solution _Item = input[i];
         ValidateValueBeforeSaveToDatabase(_Item);
     }
 }
 /// <summary>
 /// Assigns the enity reference Ids.
 /// </summary>
 /// <param name="input">The input.</param>
 public static void AssignEnityReferenceIDs(MSBuildExtensionPack.DataSourceEntities.SolutionCollection input, System.Int64 organizationId)
 {
     for (int i = 0; i < input.Count; i++)
     {
         MSBuildExtensionPack.DataSourceEntities.Solution _Item = input[i];
         _Item.OrganizationId = organizationId;
     }
 }
        /// <summary>
        /// batch delete a collection of <see cref=" MSBuildExtensionPack.DataSourceEntities.Solution"/>.
        /// http://[host]/api/SolutionApi/BatchDelete
        /// </summary>
        /// <param name="input">The input collection.</param>
        // [HttpDelete, ActionName("BatchDelete")] //although JSON allowed in Http Delete request body, but not allowed in HttpClient
        public async Task <MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn> BatchDeleteAsync(MSBuildExtensionPack.DataSourceEntities.SolutionCollection input)
        {
            string url = GetHttpRequestUrl(ActionName_BatchDelete);

            return(await Post <MSBuildExtensionPack.DataSourceEntities.SolutionCollection, MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn>(url, input));
        }
Ejemplo n.º 5
0
        public async Task <MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn> BatchDelete(MSBuildExtensionPack.DataSourceEntities.SolutionCollection input)
        {
            Task <MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn> resultTask = Task.Factory.StartNew <MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn>(() =>
            {
                MSBuildExtensionPack.CommonBLLEntities.SolutionResponseMessageBuiltIn responseMessage = MSBuildExtensionPack.CommonBLLIoC.IoCSolution.BatchDelete(input);

                return(responseMessage);
            });

            return(await resultTask);
        }