Beispiel #1
0
        public void UpdateDocumentStatus(Model.Document document)
        {
            var currentDate      = DateTime.Now;
            var existingDocument = this.GetById(document.Id);

            existingDocument.DocumentStatusId = document.DocumentStatusId;
            var documentStatus = (WorkflowStatus)document.DocumentStatusId;

            switch (documentStatus)
            {
            case WorkflowStatus.RequestForPrice:
            {
                existingDocument.IssueDate = currentDate;
                break;
            }

            case WorkflowStatus.Quotation:
            {
                break;
            }

            case WorkflowStatus.PurchaseOrder:
            {
                existingDocument.PoDate               = currentDate;
                existingDocument.PoNumber             = document.PoNumber;
                existingDocument.ExpiryDate           = document.ExpiryDate;
                existingDocument.ExpectedDeliveryDate = document.ExpectedDeliveryDate;
                existingDocument.BiddingStatusId      = (int)BiddingStatus.undefined;
                break;
            }
            }
            existingDocument.UpdatedDate = currentDate;
        }
Beispiel #2
0
        public override void Process()
        {
            Commands.GetDocument cmd;

            try
            {
                cmd = new Commands.GetDocument(_uri);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while creating the GetDocument command.", e);
                throw;
            }

            cmd.OnComplete += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Commands.ReplyBase reply)
            {
                Document = ((Commands.GetDocumentReply)reply).Document;
                TriggerOnComplete(reply);
            };
            cmd.OnError += delegate(Commands.Base sender, Http.Client client, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            cmd.OnProgress += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            cmd.OnTimeout += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection)
            {
                TriggerOnTimeout();
            };

            cmd.Execute(_sendTimeout, _receiveTimeout, _sendBufferSize, _receiveBufferSize);
        }
Beispiel #3
0
        public QPS.NEW.Model.Document GetModel(int Id)
        {
            QPS.NEW.Model.Document doc = null;

            DataTable dt = sqlHelper_.GetDataTable(
                "select * from Users where Id=@id",
                CommandType.Text,
                new System.Data.SqlClient.SqlParameter[]
                {
                    new System.Data.SqlClient.SqlParameter("@id",Id)
                }
                );

            if (dt != null && dt.Rows.Count > 0)
            {
                doc = new Model.Document();

                doc.Id = Convert.ToInt32(dt.Rows[0]["Id"]);
                doc.DTity = dt.Rows[0]["DTity"].ToString();
                doc.DContent = dt.Rows[0]["DContent"].ToString();
                doc.DType = dt.Rows[0]["DType"].ToString();
                doc.DTime = dt.Rows[0]["DTime"].ToString();

            }

            return doc;
        }
Beispiel #4
0
        public void UpdateDocumentWeightPoint(Model.Document document)
        {
            var existingDocument = this.GetById(document.Id);

            existingDocument.WeightPoint = document.WeightPoint;
            existingDocument.UpdatedDate = DateTime.Now;
        }
Beispiel #5
0
        public void AddNewDocument(Model.Document document, string customerCode)
        {
            var currentDate       = DateTime.Now;
            var currentYear       = currentDate.Year;
            var currentTH         = DateTime.Now.ToString("dd/MM/yyyy", new CultureInfo("th-TH"));
            var currentYearTH     = currentTH.Split('/').Last().Replace("/", "");
            var currentMonth      = currentDate.Month.ToString("d2");
            var nextRunningNumber = (ObjectSet.Where(i => i.CreatedDate.Value.Year == currentDate.Year).Count()) + 1;
            var nexRunningText    = ("000000" + nextRunningNumber);
            var fileNumber        = nexRunningText.Substring(nexRunningText.Length - 6, 6);
            var sub1 = fileNumber.Substring(0, 3);
            var sub2 = fileNumber.Substring(3, 3);

            document.FileNumber = string.Format("{0}{1}-{2}-{3}", currentYearTH, currentMonth, sub1, sub2);
            var documentStatus = (WorkflowStatus)document.DocumentStatusId;

            switch (documentStatus)
            {
            case WorkflowStatus.RequestForPrice:
            {
                document.IssueDate = currentDate;
                break;
            }
            }
            document.CreatedDate = currentDate;
            ObjectSet.Add(document);
        }
        public List<Security.Group> Transition(Model.View view)
        {
            List<Security.Group> groups = new List<Security.Group>();
            Group transitionGroup;
            Model.Document doc;
            JArray rows;
            int totalRows;

            try
            {
                totalRows = view["total_rows"].Value<int>();

                if (totalRows <= 0)
                    return groups;

                rows = (JArray)view["rows"];

                for (int i = 0; i < rows.Count; i++)
                {
                    transitionGroup = new Group();
                    JObject obj = (JObject)rows[i];
                    JObject a = (JObject)obj["key"];
                    doc = new Model.Document(rows[i]["key"]);
                    groups.Add(transitionGroup.Transition(doc));
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the view.", e);
                throw;
            }

            return groups;
        }
Beispiel #7
0
        public void UpdateWinLoss(Model.Document document)
        {
            var existingDocument = this.GetById(document.Id);

            existingDocument.BiddingStatusId = document.BiddingStatusId;
            existingDocument.UpdatedDate     = DateTime.Now;
        }
 protected override void ParseResponse()
 {
     switch (_response.StatusLine.StatusCode)
     {
         case 200:
             Logger.Storage.Debug("Received a successful response from CouchDB.");
             ResponseMessage = _200;
             Document = new Model.Document(StringifyResponseStream());
             Ok = true;
             Logger.Storage.Debug("GetDocumentReply loaded.");
             break;
         case 400:
             Logger.Storage.Debug("Received a failure response from CouchDB: " + _400);
             ResponseMessage = _400;
             Ok = false;
             Logger.Storage.Debug("GetDocumentReply loaded.");
             break;
         case 404:
             Logger.Storage.Debug("Received a failure response from CouchDB: " + _404);
             ResponseMessage = _404;
             Ok = false;
             Logger.Storage.Debug("GetDocumentReply loaded.");
             break;
         default:
             Logger.Storage.Error("GetDocumentReply received an unknown response code: " + _response.StatusLine.StatusCode.ToString());
             Ok = false;
             throw new UnsupportedException("The response code " + _response.StatusLine.StatusCode.ToString() + " is not supported.");
     }
 }
Beispiel #9
0
        private decimal createDoc(Model.Document pDoc)
        {
            decimal result = 0;

            using (SqlConnection con = new SqlConnection(GValues.connString))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = con;
                    command.CommandText = " INSERT INTO document(parentId, ref_docType, dateCreate, dateDoc, ref_status, xfrom, xto) " +
                                          " VALUES (@parentId, @ref_docType, @dateCreate, @dateDoc, @ref_status, @xfrom, @xto);" +
                                          " SELECT SCOPE_IDENTITY(); ";

                    command.Parameters.Add("parentId", SqlDbType.Int).Value        = pDoc.ParentId;
                    command.Parameters.Add("ref_docType", SqlDbType.Int).Value     = pDoc.DocType;
                    command.Parameters.Add("dateCreate", SqlDbType.DateTime).Value = pDoc.DateCreate;
                    command.Parameters.Add("dateDoc", SqlDbType.DateTime).Value    = pDoc.DateDoc;
                    command.Parameters.Add("ref_status", SqlDbType.Int).Value      = pDoc.RefStatus;
                    command.Parameters.Add("xfrom", SqlDbType.Int).Value           = pDoc.XFrom;
                    command.Parameters.Add("xto", SqlDbType.Int).Value             = pDoc.XTo;

                    result = (decimal)command.ExecuteScalar();
                }
            }

            return(result);
        }
Beispiel #10
0
        protected override void ParseResponse()
        {
            switch (_response.StatusLine.StatusCode)
            {
            case 200:
                Logger.Storage.Debug("Received a successful response from CouchDB.");
                ResponseMessage = _200;
                Document        = new Model.Document(StringifyResponseStream());
                Ok = true;
                Logger.Storage.Debug("GetDocumentReply loaded.");
                break;

            case 400:
                Logger.Storage.Debug("Received a failure response from CouchDB: " + _400);
                ResponseMessage = _400;
                Ok = false;
                Logger.Storage.Debug("GetDocumentReply loaded.");
                break;

            case 404:
                Logger.Storage.Debug("Received a failure response from CouchDB: " + _404);
                ResponseMessage = _404;
                Ok = false;
                Logger.Storage.Debug("GetDocumentReply loaded.");
                break;

            default:
                Logger.Storage.Error("GetDocumentReply received an unknown response code: " + _response.StatusLine.StatusCode.ToString());
                Ok = false;
                throw new UnsupportedException("The response code " + _response.StatusLine.StatusCode.ToString() + " is not supported.");
            }
        }
Beispiel #11
0
        public override void Process()
        {
            Commands.GetDocument cmd;

            try
            {
                cmd = new Commands.GetDocument(_uri);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while creating the GetDocument command.", e);
                throw;
            }

            cmd.OnComplete += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Commands.ReplyBase reply)
            {
                Document = ((Commands.GetDocumentReply)reply).Document;
                TriggerOnComplete(reply);
            };
            cmd.OnError += delegate(Commands.Base sender, Http.Client client, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            cmd.OnProgress += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            cmd.OnTimeout += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection)
            {
                TriggerOnTimeout();
            };

            cmd.Execute(_sendTimeout, _receiveTimeout, _sendBufferSize, _receiveBufferSize);
        }
Beispiel #12
0
        public List <Security.User> Transition(Model.View view)
        {
            List <Security.User> users = new List <Security.User>();
            User transitionUser;

            Model.Document doc;
            JArray         rows;
            int            totalRows;

            try
            {
                totalRows = view["total_rows"].Value <int>();

                if (totalRows <= 0)
                {
                    return(users);
                }

                rows = (JArray)view["rows"];

                for (int i = 0; i < rows.Count; i++)
                {
                    transitionUser = new User();
                    doc            = new Model.Document(rows[i]["key"]);
                    users.Add(transitionUser.Transition(doc));
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse users.", e);
                throw;
            }

            return(users);
        }
Beispiel #13
0
        public QPS.NEW.Model.Document GetModel(int Id)
        {
            QPS.NEW.Model.Document doc = null;

            DataTable dt = sqlHelper_.GetDataTable(
                "select * from Users where Id=@id",
                CommandType.Text,
                new System.Data.SqlClient.SqlParameter[]
            {
                new System.Data.SqlClient.SqlParameter("@id", Id)
            }
                );

            if (dt != null && dt.Rows.Count > 0)
            {
                doc = new Model.Document();

                doc.Id       = Convert.ToInt32(dt.Rows[0]["Id"]);
                doc.DTity    = dt.Rows[0]["DTity"].ToString();
                doc.DContent = dt.Rows[0]["DContent"].ToString();
                doc.DType    = dt.Rows[0]["DType"].ToString();
                doc.DTime    = dt.Rows[0]["DTime"].ToString();
            }

            return(doc);
        }
Beispiel #14
0
        public List <Exception> AddMetadata(string key, object value, Model.Document doc)
        {
            JProperty jprop;
            JsonSerializerSettings settings = new JsonSerializerSettings();
            List <Exception>       errors   = new List <Exception>();

            settings.Error += delegate(object sender, ErrorEventArgs args)
            {
                if (args.CurrentObject == args.ErrorContext.OriginalObject)
                {
                    errors.Add(args.ErrorContext.Error);
                }
            };

            if (errors.Count > 0)
            {
                return(errors);
            }

            if (key.StartsWith("$"))
            {
                errors.Add(new FormatException("Metadata keys cannot begin with '$'."));
                return(errors);
            }

            jprop = new JProperty(key, value);
            doc.Add(jprop);

            return(null);
        }
Beispiel #15
0
        public Model.Document Transition(Security.User user)
        {
            Model.Document doc = new Model.Document();
            JArray jarray = null;

            try
            {
                doc.Id = user.Id;
                if (user.Rev != null)
                    doc.Rev = user.Rev;
                doc["Type"] = "user";
                doc["Password"] = user.Password;
                doc["FirstName"] = user.FirstName;
                doc["MiddleName"] = user.MiddleName;
                doc["LastName"] = user.LastName;
                doc["Superuser"] = user.IsSuperuser;

                if (user.Groups != null)
                {
                    jarray = new JArray();
                    for (int i = 0; i < user.Groups.Count; i++)
                        jarray.Add(user.Groups[i]);
                }

                doc["Groups"] = jarray;
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the user.", e);
                throw;
            }

            return doc;
        }
        public List<Security.User> Transition(Model.View view)
        {
            List<Security.User> users = new List<Security.User>();
            User transitionUser;
            Model.Document doc;
            JArray rows;
            int totalRows;

            try
            {
                totalRows = view["total_rows"].Value<int>();

                if (totalRows <= 0)
                    return users;

                rows = (JArray)view["rows"];

                for (int i = 0; i < rows.Count; i++)
                {
                    transitionUser = new User();
                    doc = new Model.Document(rows[i]["key"]);
                    users.Add(transitionUser.Transition(doc));
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse users.", e);
                throw;
            }

            return users;
        }
Beispiel #17
0
        public Security.Group Transition(Model.Document document)
        {
            List <string> users = null;
            List <string> groups = null;
            JArray        usersJray, groupsJray;

            try
            {
                if (document["Groups"] != null)
                {
                    groups     = new List <string>();
                    groupsJray = (JArray)document["Groups"];

                    for (int i = 0; i < groupsJray.Count; i++)
                    {
                        string groupName = groupsJray[i].Value <string>();
                        if (groupName.StartsWith("group-"))
                        {
                            groupName = groupName.Substring(6);
                        }
                        groups.Add(groupName);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse groups.", e);
                throw;
            }

            try
            {
                if (document["Users"] != null)
                {
                    users     = new List <string>();
                    usersJray = (JArray)document["Users"];

                    for (int i = 0; i < usersJray.Count; i++)
                    {
                        string username = usersJray[i].Value <string>();
                        if (username.StartsWith("user-"))
                        {
                            username = username.Substring(5);
                        }
                        users.Add(username);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse users.", e);
                throw;
            }

            return(new Security.Group(document.Id,
                                      document.Rev,
                                      users,
                                      groups));
        }
Beispiel #18
0
        public override void TaskComplete(Tasks.Base sender, ICommandReply reply)
        {
            Type t = sender.GetType();

            if (t == typeof(Tasks.DownloadResource))
            {
                Tasks.DownloadResource task = (Tasks.DownloadResource)sender;
                _resource          = task.Resource;
                _resourceRemainder = task.Remainder;
                RunTaskProcess(new Tasks.CheckResourcePermissions(_db, _resource, _requestingPartyType,
                                                                  _session, Security.Authorization.ResourcePermissionType.Checkout, _sendTimeout, _receiveTimeout,
                                                                  _sendBufferSize, _receiveBufferSize));
            }
            else if (t == typeof(Tasks.CheckResourcePermissions))
            {
                Tasks.CheckResourcePermissions task = (Tasks.CheckResourcePermissions)sender;
                if (!task.IsAuthorized)
                {
                    TriggerOnAuthorizationDenied(task);
                    return;
                }
                RunTaskProcess(new Tasks.MarkResourceForCheckout(_resource, _session.User.Username, _sendTimeout, _receiveTimeout,
                                                                 _sendBufferSize, _receiveBufferSize));
            }
            else if (t == typeof(Tasks.MarkResourceForCheckout))
            {
                List <Exception> errors;
                Tasks.MarkResourceForCheckout task       = (Tasks.MarkResourceForCheckout)sender;
                Transitions.Resource          txResource = new Transitions.Resource();
                Model.Document doc = txResource.Transition(_resource, out errors);
                doc.CombineWith(_resourceRemainder);
                RunTaskProcess(new Tasks.UploadResource(_db, doc, _sendTimeout, _receiveTimeout,
                                                        _sendBufferSize, _receiveBufferSize));
            }
            else if (t == typeof(Tasks.UploadResource))
            {
                Tasks.UploadResource task = (Tasks.UploadResource)sender;
                if (reply.IsError)
                {
                    TriggerOnError(sender, reply.ToString(), null);
                    return;
                }
                RunTaskProcess(new Tasks.DownloadVersion(_db, _id, _sendTimeout, _receiveTimeout,
                                                         _sendBufferSize, _receiveBufferSize));
            }
            else if (t == typeof(Tasks.DownloadVersion))
            {
                Tasks.DownloadVersion task = (Tasks.DownloadVersion)sender;
                Version   = task.Version;
                Remainder = task.Remainder;
                TriggerOnComplete(reply, new Tuple <Data.Version, JObject>(Version, Remainder));
            }
            else
            {
                TriggerOnError(sender, reply.ToString(), null);
            }
        }
Beispiel #19
0
        private void treeview_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            Model.Document doc = ((TreeView)sender).SelectedItem as Model.Document;

            if (doc != null)
            {
                (DataContext as ViewModel.DocumentJournalViewModel).DataModel.CurDocument = doc;
            }
        }
Beispiel #20
0
        public Data.Version Transition(Model.Document document, out JObject remainder)
        {
            Data.Version   version;
            Data.VersionId id;
            string         rev;
            string         verifyString;

            if (!VerifyDocumentIntegrity(document, out verifyString))
            {
                Logger.Storage.Error("The document is not properly formatted.  It is missing the property '" + verifyString + "'.");
                throw new FormattingException("The argument document does not have the necessary property '" + verifyString + "'.");
            }

            try
            {
                id = new Data.VersionId(document.Id);
                if (document["_rev"] != null)
                {
                    rev     = document.Rev;
                    version = new Data.Version(id, rev);
                    document.Remove("_rev");
                }
                else
                {
                    version = new Data.Version(id);
                }

                document.Remove("_id");
                document.Remove("$type");

                version.Md5       = document["$md5"].Value <string>();
                version.Extension = document["$extension"].Value <string>();
                version.Created   = document["$created"].Value <DateTime>();
                version.Creator   = document["$creator"].Value <string>();
                version.Modified  = document["$modified"].Value <DateTime>();
                version.Modifier  = document["$modifier"].Value <string>();

                document.Remove("$md5");
                document.Remove("$extension");
                document.Remove("$created");
                document.Remove("$creator");
                document.Remove("$modified");
                document.Remove("$modifier");
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the document.", e);
                throw;
            }

            remainder = document;
            return(version);
        }
Beispiel #21
0
        private bool CheckPropertyExistance(Model.Document document, string property, out string propertyName)
        {
            propertyName = null;

            if (document[property] == null)
            {
                propertyName = property;
                return(false);
            }

            return(true);
        }
Beispiel #22
0
        private void ProcessCommon(Model.Document doc)
        {
            Remoting.SaveSingle rem;

            try
            {
                rem = new Remoting.SaveSingle(_db, doc, _sendTimeout, _receiveTimeout,
                                              _sendBufferSize, _receiveBufferSize);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while instantiating the Transactions.Tasks.Remoting.Get object.", e);
                throw;
            }

            rem.OnComplete += delegate(Remoting.Base sender, ICommandReply reply)
            {
                if (!((Commands.PutDocumentReply)reply).Ok)
                {
                    Resource = null;
                }
                else
                {
                    if (_resource != null)
                    {
                        Resource = _resource;
                        Resource.UpdateRevision(((Commands.PutDocumentReply)reply).Rev);
                    }
                    if (_jobj != null)
                    {
                        doc.Rev  = ((Commands.PutDocumentReply)reply).Rev;
                        Document = doc;
                    }
                }
                TriggerOnComplete(reply);
            };
            rem.OnError += delegate(Remoting.Base sender, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            rem.OnProgress += delegate(Remoting.Base sender, OpenDMS.Networking.Protocols.Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            rem.OnTimeout += delegate(Remoting.Base sender)
            {
                TriggerOnTimeout();
            };

            rem.Process();
        }
Beispiel #23
0
        private List <Exception> AddMetadata(Data.Version version, Model.Document doc)
        {
            List <Exception> errors = null;

            Dictionary <string, object> .Enumerator en = version.Metadata.GetEnumerator();

            while (en.MoveNext())
            {
                if ((errors = AddMetadata(en.Current.Key, en.Current.Value, doc)) != null)
                {
                    return(errors);
                }
            }

            return(null);
        }
Beispiel #24
0
 private void removeDocFromTreeRecursion(Model.Document pDoc, decimal pDocId)
 {
     foreach (Model.Document doc in pDoc.DocumentChilds)
     {
         if (doc.Id == pDocId)
         {
             pDoc.DocumentChilds.Remove(doc);
             DataModel.CurDocument = pDoc;
             break;
         }
         else
         {
             removeDocFromTreeRecursion(doc, pDocId);
         }
     }
 }
Beispiel #25
0
        public void TestSerializeDeserialize()
        {
            var m = new Model.Document();

            m.FileName = "xxx";
            m.SHA1     = "0123456789abcdef";
            var f1 = new Model.Format()
            {
                Code = "P4"
            };

            f1.Parameters.Add(new Model.Parameter()
            {
                Name = "a", Value = "1"
            });
            f1.Parameters.Add(new Model.Parameter()
            {
                Name = "b", Value = "2"
            });
            var r1 = new Model.Resource()
            {
                Name   = "res1",
                Offset = 1000,
                Format = f1
            };

            m.Resources.Add(r1);
            Model.Helper.Save(m, "test.xml");
            var zm = Model.Helper.Load <Model.Document>("test.xml");

            Assert.IsNotNull(zm);
            Assert.AreEqual(m.FileName, zm.FileName);
            Assert.AreEqual(m.Resources.Count, zm.Resources.Count);
            for (int i = 0; i < m.Resources.Count; i++)
            {
                var mr  = m.Resources[i];
                var zmr = zm.Resources[i];
                Assert.AreEqual(mr.Name, zmr.Name);
                Assert.AreEqual(mr.Offset, zmr.Offset);
                Assert.AreEqual(mr.Format.Code, zmr.Format.Code);
                for (int j = 0; j < mr.Format.Parameters.Count; j++)
                {
                    Assert.AreEqual(mr.Format.Parameters[j].Name, zmr.Format.Parameters[j].Name);
                    Assert.AreEqual(mr.Format.Parameters[j].Value, zmr.Format.Parameters[j].Value);
                }
            }
        }
Beispiel #26
0
 public ActionResult Save(Model.Document doc)
 {
     //System.Threading.Thread.Sleep(1*1000);
     if (doc.Id == Guid.Empty)
     {
         doc.Id = Guid.NewGuid();
         this.BllArticle.Add(doc);
     }
     else
     {
         this.BllArticle.EditById(doc, x => new { x.Content, x.Title, x.ContentAbstract });
     }
     return(this.Json(new Common.RT()
     {
         Status = System.Net.HttpStatusCode.OK, Msg = "保存成功", Body = new { Id = doc.Id }
     }));
 }
Beispiel #27
0
        public Model.Document Transition(Security.Group group)
        {
            Model.Document doc        = new Model.Document();
            JArray         groupsJray = null;
            JArray         usersJray  = null;

            try
            {
                doc.Id = group.Id;
                if (group.Rev != null)
                {
                    doc.Rev = group.Rev;
                }
                doc["Type"] = "group";

                if (group.Groups != null)
                {
                    groupsJray = new JArray();
                    for (int i = 0; i < group.Groups.Count; i++)
                    {
                        groupsJray.Add(group.Groups[i]);
                    }
                }

                if (group.Users != null)
                {
                    usersJray = new JArray();
                    for (int i = 0; i < group.Users.Count; i++)
                    {
                        usersJray.Add(group.Users[i]);
                    }
                }

                doc["Groups"] = groupsJray;
                doc["Users"]  = usersJray;
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the group object.", e);
                throw;
            }

            return(doc);
        }
        public IResourceUsageRightsTemplate Transition(Model.Document document)
        {
            List <Security.UsageRight> usageRights = null;

            Security.UsageRight usageRight = null;
            JProperty           prop       = null;

            try
            {
                if (document["UsageRights"] != null)
                {
                    usageRights = new List <Security.UsageRight>();
                    JArray jarray = (JArray)document["UsageRights"];

                    for (int i = 0; i < jarray.Count; i++)
                    {
                        JObject jobj            = (JObject)jarray[i];
                        IEnumerator <JToken> en = jobj.Children().GetEnumerator();
                        while (en.MoveNext())
                        {
                            prop = (JProperty)en.Current;

                            // Json.Net is giving me some weird errors here when I try to call prop.value<int>();
                            // I cannot figure out why so this code is a temporary work-around, it needs figured out.
                            string a = prop.ToString();
                            a = a.Substring(a.LastIndexOf("\"") + 1); // we know the value is an int, so we can look for the last "
                            a = a.Replace(":", "").Trim();

                            usageRight = new Security.UsageRight(prop.Name, (Security.Authorization.ResourcePermissionType) int.Parse(a));
                        }
                        usageRights.Add(usageRight);
                    }

                    //document.Remove("UsageRights");
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the document.", e);
                throw;
            }

            return(new CouchDB.ResourceUsageRightsTemplate(document.Rev, usageRights));
        }
Beispiel #29
0
 public static void OpenFile(string path)
 {
     if (!string.IsNullOrEmpty(path))
     {
         Model.Document dc = ConvertXml <Model.Document>(path);
         if (dc == null)
         {
             return;
         }
         MWin.I.Doc      = dc;
         dc.OnChange    += MWin.I.Doc_OnChange;
         MWin.I.Doc.Path = path;
         dc.Clear();
         EditUtil.RefreshSeekBar();
         EditUtil.cn_WidthChanged(null, null);
         Logging.Log.Write("Открыт файл - " + path);
         MWin.I.Title = "LEDX редактор  " + path;
     }
 }
Beispiel #30
0
        protected void initDocumentbyID(string doc_id)
        {
            DataTable dt;

            BLL.Upload _BLL = new BLL.Upload();

            Model.Document m_doc = new Model.Document();
            dt = _BLL.getDocument_By_DocId(m_doc_id);

            if (dt.Rows.Count > 0)
            {
                int x = 0;
                Int32.TryParse(dt.Rows[0]["page_count"].ToString(), out x);
                m_doc.page_count      = x;
                Session["PAPER_TYPE"] = dt.Rows[0]["paper_type"].ToString();
                Session["PAGE_COUNT"] = dt.Rows[0]["page_count"].ToString();
                Session["CONTENT"]    = dt.Rows[0]["content"].ToString();
            }
        }
Beispiel #31
0
        public List <Exception> AddMetadata(Data.Resource resource, Model.Document doc)
        {
            if (resource.Metadata == null)
            {
                return(null);
            }

            List <Exception> errors = null;

            Dictionary <string, object> .Enumerator en = resource.Metadata.GetEnumerator();

            while (en.MoveNext())
            {
                if ((errors = AddMetadata(en.Current.Key, en.Current.Value, doc)) != null)
                {
                    return(errors);
                }
            }

            return(null);
        }
Beispiel #32
0
        public void UpdateDocument(Model.Document document)
        {
            var currentDate      = DateTime.Now;
            var existingDocument = this.GetById(document.Id);

            existingDocument.DocumentStatusId   = document.DocumentStatusId;
            existingDocument.CustomerId         = document.CustomerId;
            existingDocument.ContactId          = document.ContactId;
            existingDocument.UserId             = document.UserId;
            existingDocument.ExpiryDate         = document.ExpiryDate;
            existingDocument.PoNumber           = document.PoNumber;
            existingDocument.RefPriceAndRemark  = document.RefPriceAndRemark;
            existingDocument.IsDelete           = document.IsDelete;
            existingDocument.ConfirmedPriceDays = document.ConfirmedPriceDays;
            existingDocument.DeliveryDays       = document.DeliveryDays;
            existingDocument.WeightPoint        = document.WeightPoint;
            var documentStatus = (WorkflowStatus)document.DocumentStatusId;

            switch (documentStatus)
            {
            case WorkflowStatus.RequestForPrice:
            {
                existingDocument.IssueDate = currentDate;
                break;
            }
            }
            if (document.DocumentProductItems.Count > 0)
            {
                foreach (var item in document.DocumentProductItems.Where(i => !i.IsDeleted))
                {
                    var exisingItem = existingDocument.DocumentProductItems.FirstOrDefault(i => i.Id == item.Id);
                    if (exisingItem == null)
                    {
                        existingDocument.DocumentProductItems.Add(item);
                    }
                }
            }
            existingDocument.DocumentDeliveries.FirstOrDefault().Address1 = document.DocumentDeliveries.FirstOrDefault().Address1;
            existingDocument.UpdatedDate = currentDate;
        }
        public override void Process()
        {
            Remoting.Get rem;

            TriggerOnActionChanged(EngineActionType.Searching, true);

            string query = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.ASCII.GetBytes(_args.Query.ToString()));

            try
            {
                rem = new Remoting.Get(_db, "_fti/_design/search/main?q=" + query, _sendTimeout, _receiveTimeout,
                                       _sendBufferSize, _receiveBufferSize);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while instantiating the Transactions.Tasks.Remoting.Get object.", e);
                throw;
            }

            rem.OnComplete += delegate(Remoting.Base sender, ICommandReply reply)
            {
                Document = ((Commands.GetDocumentReply)reply).Document;
                TriggerOnComplete(reply);
            };
            rem.OnError += delegate(Remoting.Base sender, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            rem.OnProgress += delegate(Remoting.Base sender, OpenDMS.Networking.Protocols.Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            rem.OnTimeout += delegate(Remoting.Base sender)
            {
                TriggerOnTimeout();
            };

            rem.Process();
        }
Beispiel #34
0
        public override void Process()
        {
            Remoting.Get rem;

            TriggerOnActionChanged(EngineActionType.Searching, true);

            string query = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.ASCII.GetBytes(_args.Query.ToString()));
            
            try
            {
                rem = new Remoting.Get(_db, "_fti/_design/search/main?q=" + query, _sendTimeout, _receiveTimeout,
                    _sendBufferSize, _receiveBufferSize);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while instantiating the Transactions.Tasks.Remoting.Get object.", e);
                throw;
            }

            rem.OnComplete += delegate(Remoting.Base sender, ICommandReply reply)
            {
                Document = ((Commands.GetDocumentReply)reply).Document;
                TriggerOnComplete(reply);
            };
            rem.OnError += delegate(Remoting.Base sender, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            rem.OnProgress += delegate(Remoting.Base sender, OpenDMS.Networking.Protocols.Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            rem.OnTimeout += delegate(Remoting.Base sender)
            {
                TriggerOnTimeout();
            };

            rem.Process();
        }
Beispiel #35
0
        public Security.User Transition(Model.Document document)
        {
            List <string> groups = null;

            try
            {
                if (document["Groups"] != null)
                {
                    groups = new List <string>();
                    JArray jarray = (JArray)document["Groups"];

                    for (int i = 0; i < jarray.Count; i++)
                    {
                        string groupName = jarray[i].Value <string>();
                        if (groupName.StartsWith("group-"))
                        {
                            groupName = groupName.Substring(6);
                        }
                        groups.Add(groupName);
                    }
                }

                Security.User user = new Security.User(document.Id,
                                                       document.Rev,
                                                       null,
                                                       document["FirstName"].Value <string>(),
                                                       document["MiddleName"].Value <string>(),
                                                       document["LastName"].Value <string>(),
                                                       groups,
                                                       document["Superuser"].Value <bool>());
                user.SetEncryptedPassword(document["Password"].Value <string>());
                return(user);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the document.", e);
                throw;
            }
        }
Beispiel #36
0
        private bool VerifyDocumentIntegrity(Model.Document document, out string property)
        {
            property = null;

            if (!CheckPropertyExistance(document, "_id", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$type", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$md5", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$extension", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$created", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$creator", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$modified", out property))
            {
                return(false);
            }
            if (!CheckPropertyExistance(document, "$modifier", out property))
            {
                return(false);
            }

            return(true);
        }
Beispiel #37
0
        private void CreateDoc(object obj)
        {
            Model.Document doc = new Model.Document
            {
                DocType = Convert.ToDecimal(obj)
            };

            try
            {
                doc.Id = createDoc(doc);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, GValues.AppNameFull, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            DataModel.Documents.Add(doc);
            DataModel.CurDocument = doc;

            showDoc();
        }
Beispiel #38
0
        public Model.Document Transition(Security.Group group)
        {
            Model.Document doc = new Model.Document();
            JArray groupsJray = null;
            JArray usersJray = null;

            try
            {
                doc.Id = group.Id;
                if (group.Rev != null)
                    doc.Rev = group.Rev;
                doc["Type"] = "group";

                if (group.Groups != null)
                {
                    groupsJray = new JArray();
                    for (int i = 0; i < group.Groups.Count; i++)
                        groupsJray.Add(group.Groups[i]);
                }

                if (group.Users != null)
                {
                    usersJray = new JArray();
                    for (int i = 0; i < group.Users.Count; i++)
                        usersJray.Add(group.Users[i]);
                }

                doc["Groups"] = groupsJray;
                doc["Users"] = usersJray;
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the group object.", e);
                throw;
            }

            return doc;
        }
        public Model.Document Transition(IResourceUsageRightsTemplate rights)
        {
            Model.Document document = new Model.Document();
            JArray jarray;

            try
            {
                document.Id = rights.Id;

                if (!string.IsNullOrEmpty(rights.Revision))
                    document.Rev = rights.Revision;

                document["Type"] = "resourceusagerightstemplate";

                if (rights.UsageRights != null && rights.UsageRights.Count > 0)
                {
                    jarray = new JArray();

                    for (int i = 0; i < rights.UsageRights.Count; i++)
                    {
                        JObject jobj = new JObject();
                        jobj.Add(new JProperty(rights.UsageRights[i].Entity, (int)rights.UsageRights[i].Permissions.Resource.Permissions));
                        jarray.Add(jobj);
                    }

                    document.Add("UsageRights", jarray);
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the resource object.", e);
                throw;
            }

            return document;
        }
Beispiel #40
0
        public Data.Resource Transition(Model.Document document, out JObject remainder)
        {
            Data.Resource resource;
            Data.ResourceId id;
            string rev = null;
            Data.VersionId currentVersionId;
            List<Data.VersionId> versionIds = null;
            List<Security.UsageRight> usageRights = null;
            Security.UsageRight usageRight = null;
            JObject jobj = null;
            JProperty prop = null;
            IEnumerator<JToken> en;
            string verifyString;
            JArray jarray = new JArray();

            if (!VerifyDocumentIntegrity(document, out verifyString))
            {
                Logger.Storage.Error("The document is not properly formatted.  It is missing the property '" + verifyString + "'.");
                throw new FormattingException("The argument document does not have the necessary property '" + verifyString + "'.");
            }

            // I ran into a problem here where I was removing the properties from the document and what was left was the remainder.
            // However, this causes an issue when using the transition to make a resource for permissions checking as the
            // object returned to implementing software is the document.  Thus, the implementing software only received those properties
            // not removed... which obviously excludes the most important properties.  To remedy this issue, I created a constructor for
            // Model.Document(Document).  This constructor will format the argument document to a string and then create a JObject from 
            // that string.  C# will deep copy the string (not byref) so as to guarantee an independent object.
            remainder = new Model.Document(document);

            try
            {
                id = new Data.ResourceId(document.Id);
                if (document["_rev"] != null)
                {
                    rev = document.Rev;
                    remainder.Remove("_rev");
                }
                
                remainder.Remove("_id");
                remainder.Remove("$type");

                currentVersionId = new Data.VersionId(document["$currentversionid"].Value<string>());
                remainder.Remove("$currentversionid");

                versionIds = new List<Data.VersionId>();
                jarray = (JArray)document["$versionids"];

                for (int i = 0; i < jarray.Count; i++)
                    versionIds.Add(new Data.VersionId(jarray[i].Value<string>()));

                remainder.Remove("$versionids");


                usageRights = new List<Security.UsageRight>();
                jarray = (JArray)document["$usagerights"];

                for (int i = 0; i < jarray.Count; i++)
                {
                    jobj = (JObject)jarray[i];
                    en = jobj.Children().GetEnumerator();
                    while (en.MoveNext())
                    {
                        prop = (JProperty)en.Current;

                        // Json.Net is giving me some weird errors here when I try to call prop.value<int>();
                        // I cannot figure out why so this code is a temporary work-around, it needs figured out.
                        string a = prop.ToString();
                        a = a.Substring(a.LastIndexOf("\"") + 1); // we know the value is an int, so we can look for the last "
                        a = a.Replace(":", "").Trim();

                        usageRight = new Security.UsageRight(prop.Name, (Security.Authorization.ResourcePermissionType)int.Parse(a));
                        usageRights.Add(usageRight);
                    }
                }

                remainder.Remove("$usagerights");

                resource = new Data.Resource(id, rev, versionIds, currentVersionId, new Data.Metadata(), usageRights);

                // Tags
                resource.Tags = new List<string>();
                jarray = (JArray)document["$tags"];
                for (int i = 0; i < jarray.Count; i++)
                    resource.Tags.Add(jarray[i].Value<string>());
                remainder.Remove("$tags");

                resource.Created = document["$created"].Value<DateTime>();
                resource.Creator = document["$creator"].Value<string>();
                resource.Modified = document["$modified"].Value<DateTime>();
                resource.Modifier = document["$modifier"].Value<string>();
                resource.CheckedOutAt = document["$checkedoutat"].Value<DateTime>();
                resource.CheckedOutTo = document["$checkedoutto"].Value<string>();
                resource.LastCommit = document["$lastcommit"].Value<DateTime>();
                resource.LastCommitter = document["$lastcommitter"].Value<string>();
                resource.Title = document["$title"].Value<string>();

                remainder.Remove("$created");
                remainder.Remove("$creator");
                remainder.Remove("$modified");
                remainder.Remove("$modifier");
                remainder.Remove("$checkedoutat");
                remainder.Remove("$checkedoutto");
                remainder.Remove("$lastcommit");
                remainder.Remove("$lastcommitter");
                remainder.Remove("$title");
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the document.", e);
                throw;
            }

            return resource;
        }
Beispiel #41
0
        public Model.Document Transition(Data.Resource resource, out List<Exception> errors)
        {
            Model.Document document = new Model.Document();
            JArray jarray;
            string prop;

            try
            {
                document.Id = resource.ResourceId.ToString();
                if (!string.IsNullOrEmpty(resource.Revision))
                    document.Rev = resource.Revision;
                document["$type"] = "resource";

                jarray = new JArray();
                for (int i = 0; i < resource.VersionIds.Count; i++)
                    jarray.Add(resource.VersionIds[i].ToString());
                document.Add("$versionids", jarray);


                jarray = new JArray();
                for (int i = 0; i < resource.UsageRights.Count; i++)
                {
                    JObject jobj = new JObject();
                    jobj.Add(new JProperty(resource.UsageRights[i].Entity, (int)resource.UsageRights[i].Permissions.Resource.Permissions));
                    jarray.Add(jobj);
                }
                document.Add("$usagerights", jarray);

                if (resource.CurrentVersionId != null)
                    document.Add("$currentversionid", resource.CurrentVersionId.ToString());


                jarray = new JArray();
                for (int i = 0; i < resource.Tags.Count; i++)
                    jarray.Add(resource.Tags[i]);
                document.Add("$tags", jarray);

                document.Add("$created", resource.Created);
                document.Add("$creator", resource.Creator);
                document.Add("$modified", resource.Modified);
                document.Add("$modifier", resource.Modifier);
                document.Add("$checkedoutat", resource.CheckedOutAt);
                document.Add("$checkedoutto", resource.CheckedOutTo);
                document.Add("$lastcommit", resource.LastCommit);
                document.Add("$lastcommitter", resource.LastCommitter);
                document.Add("$title", resource.Title);

                if ((errors = AddMetadata(resource, document)) != null)
                    return null;

                if(!VerifyDocumentIntegrity(document, out prop))
                {
                    Logger.Storage.Error("The document is not properly formatted.  It is missing the property '" + prop + "'.");
                    throw new FormattingException("The argument document does not have the necessary property '" + prop + "'.");
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the resource object.", e);
                throw;
            }

            return document;
        }
Beispiel #42
0
        public Model.Document Transition(Data.Version version, out List<Exception> errors)
        {
            Model.Document document = new Model.Document();
            Model.Attachment att = null;
            string prop;

            errors = null;

            try
            {
                document.Id = version.VersionId.ToString();
                if (!string.IsNullOrEmpty(version.Revision))
                    document.Rev = version.Revision;

                document.Add("$type", "version");
                document.Add("$md5", version.Md5);
                document.Add("$extension", version.Extension);
                document.Add("$created", version.Created);
                document.Add("$creator", version.Creator);
                document.Add("$modified", version.Modified);
                document.Add("$modifier", version.Modifier);

                if (version.Metadata != null)
                {
                    if ((errors = AddMetadata(version, document)) != null)
                        return null;
                }

                if (version.Content != null)
                {
                    att = new Model.Attachment();
                    att.ContentType = version.Content.ContentType.Name;
                    att.AttachmentLength = version.Content.Length;
                    if (string.IsNullOrEmpty(version.Content.LocalFilepath))
                        document.AddAttachment("file", att);
                    else
                        document.AddAttachment(System.IO.Path.GetFileName(version.Content.LocalFilepath), att);
                }

                if (!VerifyDocumentIntegrity(document, out prop))
                {
                    Logger.Storage.Error("The document is not properly formatted.  It is missing the property '" + prop + "'.");
                    throw new FormattingException("The argument document does not have the necessary property '" + prop + "'.");
                }
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while attempting to parse the version object.", e);
                throw;
            }

            return document;
        }
        private void ProcessCommon(Model.Document doc)
        {
            Remoting.SaveSingle rem;

            try
            {
                rem = new Remoting.SaveSingle(_db, doc, _sendTimeout, _receiveTimeout,
                    _sendBufferSize, _receiveBufferSize);
            }
            catch (Exception e)
            {
                Logger.Storage.Error("An exception occurred while instantiating the Transactions.Tasks.Remoting.Get object.", e);
                throw;
            }

            rem.OnComplete += delegate(Remoting.Base sender, ICommandReply reply)
            {
                if (!((Commands.PutDocumentReply)reply).Ok)
                    Resource = null;
                else
                {
                    if (_resource != null)
                    {
                        Resource = _resource;
                        Resource.UpdateRevision(((Commands.PutDocumentReply)reply).Rev);
                    }
                    if (_jobj != null)
                    {
                        doc.Rev = ((Commands.PutDocumentReply)reply).Rev;
                        Document = doc;
                    }
                }
                TriggerOnComplete(reply);
            };
            rem.OnError += delegate(Remoting.Base sender, string message, Exception exception)
            {
                TriggerOnError(message, exception);
            };
            rem.OnProgress += delegate(Remoting.Base sender, OpenDMS.Networking.Protocols.Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete)
            {
                TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete);
            };
            rem.OnTimeout += delegate(Remoting.Base sender)
            {
                TriggerOnTimeout();
            };

            rem.Process();
        }
Beispiel #44
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            Model.Document document = new Model.Document();

            int indexDocumentId = dr.GetOrdinal("DocumentId");
            document.DocumentId = Convert.ToInt32(dr[indexDocumentId]);

            int indexOrderId = dr.GetOrdinal("OrderId");
            if (dr["OrderId"] != DBNull.Value)
            {
                document.OrderId = Convert.ToInt32(dr[indexOrderId]);
            }

            int indexDocumentDate = dr.GetOrdinal("DocumentDate");
            if (dr["DocumentDate"] != DBNull.Value)
            {
                document.DocumentDate = Convert.ToDateTime(dr[indexDocumentDate]);
            }

            int indexDocEmpId = dr.GetOrdinal("DocEmpId");
            if (dr["DocEmpId"] != DBNull.Value)
            {
                document.DocEmpId = Convert.ToInt32(dr[indexDocEmpId]);
            }

            int indexPresentDate = dr.GetOrdinal("PresentDate");
            if (dr["PresentDate"] != DBNull.Value)
            {
                document.PresentDate = Convert.ToDateTime(dr[indexPresentDate]);
            }

            int indexPresenter = dr.GetOrdinal("Presenter");
            if (dr["Presenter"] != DBNull.Value)
            {
                document.Presenter = Convert.ToInt32(dr[indexPresenter]);
            }

            int indexAcceptanceDate = dr.GetOrdinal("AcceptanceDate");
            if (dr["AcceptanceDate"] != DBNull.Value)
            {
                document.AcceptanceDate = Convert.ToDateTime(dr[indexAcceptanceDate]);
            }

            int indexAcceptancer = dr.GetOrdinal("Acceptancer");
            if (dr["Acceptancer"] != DBNull.Value)
            {
                document.Acceptancer = Convert.ToInt32(dr[indexAcceptancer]);
            }

            int indexMeno = dr.GetOrdinal("Meno");
            if (dr["Meno"] != DBNull.Value)
            {
                document.Meno = Convert.ToString(dr[indexMeno]);
            }

            int indexDocumentStatus = dr.GetOrdinal("DocumentStatus");
            if (dr["DocumentStatus"] != DBNull.Value)
            {
                document.DocumentStatus = (DocumentStatusEnum)Convert.ToInt32(dr[indexDocumentStatus]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            if (dr["CreatorId"] != DBNull.Value)
            {
                document.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
            }

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            if (dr["CreateTime"] != DBNull.Value)
            {
                document.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
            }

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                document.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                document.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return document;
        }