Ejemplo n.º 1
0
        public int SaveDocument(DocumentInfo documentInfo)
        {
            Data.Document document = ConvertToDb(documentInfo);

            _context.Documents.Add(document);
            _context.SaveChanges();

            return(document.Id);
        }
Ejemplo n.º 2
0
 private void NewDocument()
 {
     Data.ConnectionDetails connectionDetails = _document.ConnectionDetails.Clone();
     _fileName = null;
     _document = new Data.Document();
     _document.ConnectionDetails = connectionDetails;
     _queryTextbox.Clear();
     _resultsControl.Clear();
     UpdateCaption();
 }
Ejemplo n.º 3
0
 public DocumentInfo ConvertToFacade(Data.Document document)
 {
     return(new DocumentInfo
     {
         Id = document.Id,
         DocumentPath = document.DocumentPath,
         DocumentType = document.DocumentType,
         FileName = document.FileName,
         UploadDate = document.UploadDate,
         EmployeeInfoId = document.EmployeeInfoId
     });
 }
Ejemplo n.º 4
0
        public void DeleteDocument(int id)
        {
            Data.Document document = _context.Documents.Find(id);

            if (document != null)
            {
                _context.Documents.Remove(document);
                _context.SaveChanges();
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
Ejemplo n.º 5
0
        public DocumentInfo GetDocumentById(int id)
        {
            Data.Document document = _context.Documents.Find(id);

            if (document != null)
            {
                return(ConvertToFacade(document));
            }
            else
            {
                DocumentInfo documentInfo = new DocumentInfo();
                documentInfo = null;

                return(documentInfo);
            }
        }
Ejemplo n.º 6
0
        private async Task Save(Address sender, Hash hash, byte[] data, string name)
        {
            var document = await dataService.Load(hash);

            if (document == null)
            {
                document = new Data.Document()
                {
                    Hash  = hash,
                    Owner = sender,
                    Name  = name
                };
                using (var ms = new MemoryStream(data)) {
                    if (!await storageService.Store(hash, ms))
                    {
                        throw new StorageException();
                    }
                }
                await dataService.Save(document);
            }
        }
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid){
         Data.Document obj = new Data.Document();
         obj.Id = Id;
         obj.Code = txtCode.Text;
         obj.Name = txtName.Text;
         obj.CreateDate = DateTimeClass.ConvertDateTime(txtCreateDate.Text, "MM/dd/yyyy");
         obj.EffectiveDate = DateTimeClass.ConvertDateTime(txtEffectiveDate.Text, "MM/dd/yyyy");
         obj.Info = fckInfo.Value;
         obj.File = txtFile.Text;
         obj.Priority = chkPriority.Checked ? "1" : "0";
         obj.Active = chkActive.Checked ? "1" : "0";
         obj.Lang = Lang;
         obj.TypeId = ddlDocumentType.SelectedValue;
         if (Insert == true){
             DocumentService.Document_Insert(obj);
         }
         else{
             DocumentService.Document_Update(obj);
         }
         BindGrid();
         pnView.Visible = true;
         pnUpdate.Visible = false;
         Insert = false;
     }
 }
Ejemplo n.º 8
0
 public IActionResult Index(int id)
 {
     Data.Document document = Data.Index.GetDocument(id);
     return(View(document));
 }
Ejemplo n.º 9
0
 public Document(Data.Document document)
 {
     Id     = document.Id;
     TaskId = document.TaskId;
 }
Ejemplo n.º 10
0
        public void Update(Data.Document doc, IList <Query.DocumentResultForSort> docs)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendFormat("update {0} set ", Table.DBTableName);

            int i = 0;

            foreach (Data.FieldValue fv in doc.FieldValues)
            {
                string value;

                if (fv.Value == null)
                {
                    value = "NULL";
                }
                else
                {
                    value = fv.Type == Data.DataType.Varchar || fv.Type == Data.DataType.NVarchar ||
                            fv.Type == Data.DataType.NChar || fv.Type == Data.DataType.Char ||
                            fv.Type == Data.DataType.Date || fv.Type == Data.DataType.DateTime ||
                            fv.Type == Data.DataType.SmallDateTime || fv.Type == Data.DataType.Data ?
                            string.Format("'{0}'", fv.Value.Replace("'", "''")) : fv.Value;
                }

                if (i++ == 0)
                {
                    sql.AppendFormat("[{0}]={1}", fv.FieldName, value);
                }
                else
                {
                    sql.AppendFormat(",[{0}]={1}", fv.FieldName, value);
                }
            }

            if (DocIdReplaceField == null)
            {
                sql.Append(" where docId in (");
            }
            else
            {
                sql.AppendFormat(" where {0} in (", DocIdReplaceField);
            }


            i = 0;

            foreach (Query.DocumentResultForSort docResult in docs)
            {
                int docId = docResult.DocId;

                if (DocIdReplaceField == null)
                {
                    if (i++ == 0)
                    {
                        sql.AppendFormat("{0}", docId);
                    }
                    else
                    {
                        sql.AppendFormat(",{0}", docId);
                    }
                }
                else
                {
                    long replaceFieldValue = this.DBProvider.GetDocIdReplaceFieldValue(docId);

                    if (i++ == 0)
                    {
                        sql.AppendFormat("{0}", replaceFieldValue);
                    }
                    else
                    {
                        sql.AppendFormat(",{0}", replaceFieldValue);
                    }
                }
            }

            sql.Append(")");

            using (SQLDataProvider sqlData = new SQLDataProvider())
            {
                sqlData.Connect(Table.ConnectionString);
                sqlData.ExcuteSql(sql.ToString());
            }
        }
Ejemplo n.º 11
0
        public HttpResponseMessage UploadDocument()
        {
            var    UploadPath = "";
            string path       = "";

            Data.Document docObj = new Data.Document();
            foreach (string file in HttpContext.Current.Request.Files)
            {
                var FileDataContent = System.Web.HttpContext.Current.Request.Files[file];
                var myObject        = System.Web.HttpContext.Current.Request;
                docObj.UserId   = myObject.Form["UserId"];
                docObj.SchoolId = Convert.ToInt32(myObject.Form["SchoolId"]);
                if (!string.IsNullOrEmpty(myObject.Form["ClassId"]))
                {
                    docObj.ClassId = Convert.ToInt32(myObject.Form["ClassId"]);
                }
                docObj.CreatedDate = DateTime.Now;
                docObj.UpdatedDate = DateTime.Now;
                var guidKey = Guid.NewGuid();
                if (FileDataContent != null && FileDataContent.ContentLength > 0)
                {
                    try
                    {
                        var stream   = FileDataContent.InputStream;
                        var fileName = guidKey + "_" + FileDataContent.FileName;
                        docObj.DocumentName = fileName;
                        string pathToFiles = HttpContext.Current.Server.MapPath("~/SchoolWepAPI");
                        UploadPath = pathToFiles + "\\FileStore\\" + docObj.SchoolId + "\\";
                        Directory.CreateDirectory(UploadPath);
                        path = Path.Combine(UploadPath, fileName);

                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                        using (var fileStream = System.IO.File.Create(path))
                        {
                            stream.CopyTo(fileStream);
                            fileStream.Dispose();

                            try
                            {
                                this._dbContext.Documents.Add(docObj);
                                this._dbContext.SaveChanges();
                            }
                            catch (Exception Ex)
                            {
                                if (System.IO.File.Exists(path))
                                {
                                    System.IO.File.Delete(path);
                                }
                                return(new HttpResponseMessage()
                                {
                                    StatusCode = System.Net.HttpStatusCode.InternalServerError,
                                    Content = new StringContent("Document upload failed."),
                                    ReasonPhrase = "Document upload failed."
                                });
                            }
                        }
                    }
                    catch (IOException ex)
                    {
                        return(new HttpResponseMessage()
                        {
                            StatusCode = System.Net.HttpStatusCode.InternalServerError,
                            Content = new StringContent("Document upload failed."),
                            ReasonPhrase = "Document upload failed."
                        });
                    }
                }
            }

            return(new HttpResponseMessage()
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content = new StringContent("Document uploaded successfully."),
                ReasonPhrase = string.Empty
            });
        }
Ejemplo n.º 12
0
        public void Update(Data.Document doc, IList <Query.DocumentResultForSort> docs)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("DECLARE @ptrval binary(16)");

            int textFieldCount = 0;

            StringBuilder writeTextString = new StringBuilder();

            foreach (Data.FieldValue fv in doc.FieldValues)
            {
                switch (fv.Type)
                {
                case Hubble.Core.Data.DataType.Varchar:
                case Hubble.Core.Data.DataType.NVarchar:
                case Hubble.Core.Data.DataType.Char:
                case Hubble.Core.Data.DataType.NChar:
                    if (fv.DataLength <= 0)
                    {
                        textFieldCount++;

                        foreach (Query.DocumentResultForSort mydoc in docs)
                        {
                            writeTextString.AppendLine(BuildWriteTextLine(Table.DBTableName,
                                                                          fv.FieldName, fv.Value.Replace("'", "''"), mydoc.DocId, fv.Type));
                        }
                    }
                    break;
                }
            }

            if (textFieldCount < doc.FieldValues.Count)
            {
                sql.AppendFormat("update {0} set ", Table.DBTableName);

                int i = 0;

                foreach (Data.FieldValue fv in doc.FieldValues)
                {
                    string value;

                    if (fv.Value == null)
                    {
                        value = "NULL";
                    }
                    else
                    {
                        value = fv.Type == Data.DataType.Varchar || fv.Type == Data.DataType.NVarchar ||
                                fv.Type == Data.DataType.NChar || fv.Type == Data.DataType.Char ||
                                fv.Type == Data.DataType.Date || fv.Type == Data.DataType.DateTime ||
                                fv.Type == Data.DataType.SmallDateTime || fv.Type == Data.DataType.Data ?
                                string.Format("'{0}'", fv.Value.Replace("'", "''")) : fv.Value;
                    }

                    if (i++ == 0)
                    {
                        sql.AppendFormat("[{0}]={1}", fv.FieldName, value);
                    }
                    else
                    {
                        sql.AppendFormat(",[{0}]={1}", fv.FieldName, value);
                    }
                }

                if (DocIdReplaceField == null)
                {
                    sql.Append(" where docId in (");
                }
                else
                {
                    sql.AppendFormat(" where {0} in (", DocIdReplaceField);
                }

                i = 0;

                foreach (Query.DocumentResultForSort docResult in docs)
                {
                    int docId = docResult.DocId;

                    if (DocIdReplaceField == null)
                    {
                        if (i++ == 0)
                        {
                            sql.AppendFormat("{0}", docId);
                        }
                        else
                        {
                            sql.AppendFormat(",{0}", docId);
                        }
                    }
                    else
                    {
                        long replaceFieldValue = this.DBProvider.GetDocIdReplaceFieldValue(docId);

                        if (i++ == 0)
                        {
                            sql.AppendFormat("{0}", replaceFieldValue);
                        }
                        else
                        {
                            sql.AppendFormat(",{0}", replaceFieldValue);
                        }
                    }
                }

                sql.Append(")");
            }

            sql.AppendLine(writeTextString.ToString());

            using (SQLDataProvider sqlData = new SQLDataProvider())
            {
                sqlData.Connect(Table.ConnectionString);
                sqlData.ExcuteSql(sql.ToString());
            }
        }