public async Task <dynamic> AddVersionDocumentInfo(DocumentsInfo _modelDocumentsInfo) { DSM_DocPropIdentify objDocPropIdentifies = new DSM_DocPropIdentify(); if (ModelState.IsValid) { action = "add"; _modelDocumentsInfo.SetBy = UserID; _modelDocumentsInfo.ModifiedBy = _modelDocumentsInfo.SetBy; _modelDocumentsInfo.UploaderIP = GetIPAddress.LocalIPAddress(); respStatus.Message = "Success"; respStatus = await Task.Run(() => _versioningOfOriginalDocService.AddVersionDocumentInfo( _modelDocumentsInfo, action, out objDocPropIdentifies)); try { FolderGenerator.MakeFTPDir(objDocPropIdentifies.ServerIP, objDocPropIdentifies.ServerPort, objDocPropIdentifies.FileServerUrl, objDocPropIdentifies.FtpUserName, objDocPropIdentifies.FtpPassword); } catch (Exception e) { } return(Json(new { Message = respStatus.Message, result = objDocPropIdentifies, //DistinctID = DistinctDocIDs }, JsonRequestBehavior.AllowGet)); } else { //var errors = ModelState.Values.SelectMany(v => v.Errors); respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } }
public async Task <dynamic> AddDocumentInfo(DocumentsInfo _modelDocumentsInfo, string _selectedPropID, List <DocMetaValue> _docMetaValues) { List <DSM_DocPropIdentify> objDocPropIdentifies = null; if (ModelState.IsValid) { action = "add"; _modelDocumentsInfo.SetBy = UserID; _modelDocumentsInfo.ModifiedBy = _modelDocumentsInfo.SetBy; _modelDocumentsInfo.UploaderIP = GetIPAddress.LocalIPAddress(); respStatus.Message = "Success"; respStatus = await Task.Run(() => _multiDocScanService.AddDocumentInfo(_modelDocumentsInfo, _selectedPropID, _docMetaValues, action, out objDocPropIdentifies)); var DistinctDocIDs1 = (from s in objDocPropIdentifies group s by new { s.DocumentID } into g select new { DocPropID = g.Select(p => p.DocPropertyID).FirstOrDefault(), DocumentID = g.Select(p => p.DocumentID).FirstOrDefault(), FileServerUrl = g.Select(x => x.FileServerUrl).FirstOrDefault() }).ToList(); List <DSM_DocProperty> proplList = new List <DSM_DocProperty>(); string[] docPropIDs = _selectedPropID.Split(','); foreach (var item in docPropIDs) { DSM_DocProperty objDocProperty = new DSM_DocProperty(); objDocProperty.DocPropertyID = item; proplList.Add(objDocProperty); } var DistinctDocIDs = (from p in proplList join d in DistinctDocIDs1 on p.DocPropertyID equals d.DocPropID select new { DocPropID = d.DocPropID, DocumentID = d.DocumentID, FileServerUrl = d.FileServerUrl }).ToList(); foreach (var item in DistinctDocIDs) { try { FolderGenerator.MakeFTPDir(objDocPropIdentifies.FirstOrDefault().ServerIP, objDocPropIdentifies.FirstOrDefault().ServerPort, item.FileServerUrl, objDocPropIdentifies.FirstOrDefault().FtpUserName, objDocPropIdentifies.FirstOrDefault().FtpPassword); } catch (Exception e) { } } return(Json(new { Message = respStatus.Message, result = objDocPropIdentifies, DistinctID = DistinctDocIDs }, JsonRequestBehavior.AllowGet)); } else { //var errors = ModelState.Values.SelectMany(v => v.Errors); respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } }