Esempio n. 1
0
        public virtual object Read(out string DocSrc, string DocData, out Dictionary <string, string> DocKeys, string RelayUrl = null)
        {
            BaseDoc _BaseDoc = DocInterpreter.Instance.Read(DocData);

            DocKeys = DocKey.DocIdToKeys(((IDocIdentifiers)_BaseDoc).DocId);
            return(Create(out DocSrc, _BaseDoc, DocKeys, RelayUrl, false));
        }
Esempio n. 2
0
        /// <summary>
        ///     XmlSerialize object without processing instructions, remove all tags & collapse any white-space to a single space,
        ///     convert all apply ToLocalTime to all DateTime properties
        /// </summary>
        /// <param name="baseDoc"></param>
        /// <returns></returns>
        public static int CalcDocChecksum(BaseDoc baseDoc, bool?docStatus = null)
        {
            docStatus = docStatus ?? baseDoc.DocStatus;

            // absolutely necessary the object is not altered in any way shape of form
            baseDoc = baseDoc.Clone();

            // normalize the datetime properties since they are mangled in the XmlSerialization/DataContractSerilaization process(s)
            foreach (PropertyInfo p in
                     baseDoc.GetType()
                     .GetProperties()
                     .ToArray()
                     .Where(p => (Nullable.GetUnderlyingType(p.PropertyType) ?? p.PropertyType) == typeof(DateTime)))
            {
                p.SetValue(baseDoc,
                           ((DateTime)(p.GetValue(baseDoc,
                                                  null) ?? DateTime.MinValue)).ToLocalTime(),
                           null);
            }

            //TODO:Add signature parse logic
            return(Regex.Replace(Regex.Replace(
                                     DocInterpreter.Instance.Write(baseDoc, false),
                                     "</?[a-z][a-z0-9]*[^<>]*>|<!--.*?-->",
                                     "",
                                     RegexOptions.Singleline | RegexOptions.IgnoreCase),
                                 @"\s+",
                                 " ",
                                 RegexOptions.Singleline | RegexOptions.IgnoreCase).GetHashCode() ^ (docStatus ?? false).GetHashCode());
        }
Esempio n. 3
0
        /// <summary>
        ///     if the DocData is less then 2083 characters long (that is internet explorer's address bar limit), inline the actual
        ///     data to the URL. When that can't be achieved the document will be stored in MemoryCache and a quazi-ticket-number
        ///     will URL parameter will be used guaranteeing availability of anything that requests it within 10 minutes of this
        ///     method being called.
        /// </summary>
        /// <param name="BaseDoc"></param>
        /// <param name="RelayUrl"></param>
        /// <returns></returns>
        public static string ToUrl(BaseDoc BaseDoc, string RelayUrl = null)
        {
            if (string.IsNullOrWhiteSpace(RelayUrl))
            {
                RelayUrl = DCF_Relay.DCF_Relay.GetRelayUrl();
            }

            string DocTypeName = BaseDoc.DocTypeName;

            string _Url = string.IsNullOrWhiteSpace(RelayUrl)
                              ? string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}",
                                              RequestPaths.ApplicationPath,
                                              DocTypeName,
                                              Parm.DocBin,
                                              HttpUtility.UrlEncode(Compressor.CompressToBase64String(BaseDoc.ToBytes())))
                              : string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}&{4}={5}",
                                              RelayUrl,
                                              DocTypeName,
                                              Parm.DocBin,
                                              HttpUtility.UrlEncode(Compressor.CompressToBase64String(BaseDoc.ToBytes())),
                                              Parm.RelayUrl,
                                              HttpUtility.UrlEncode(RelayUrl)
                                              );

            //REF:http://support.microsoft.com/kb/208427
            if (_Url.Length > 2083)
            {
                string _CacheKey = HttpUtility.UrlEncode(string.Format("{0}.{1}", DocTypeName, _Url.GetHashCode()));

                if (HttpRuntime.Cache[_CacheKey] == null)
                {
                    HttpRuntime.Cache.Insert(_CacheKey,
                                             BaseDoc,
                                             null,
                                             Cache.NoAbsoluteExpiration,
                                             TimeSpan.FromMinutes(10));
                }

                _Url = string.IsNullOrWhiteSpace(RelayUrl)
                           ? string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}",
                                           RequestPaths.ApplicationPath,
                                           DocTypeName,
                                           Parm.DocCache,
                                           _CacheKey)
                           : string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}&{4}={5}",
                                           RelayUrl,
                                           DocTypeName,
                                           Parm.DocCache,
                                           _CacheKey,
                                           Parm.RelayUrl,
                                           HttpUtility.UrlEncode(RelayUrl));
            }
            return(RelayUrl != "~"
                       ? _Url
                       : ResolveUrl(_Url)); //TODO:Clean this slop up... In fact, clean the whole FormHandlerNavigation up; it sucks
        }
Esempio n. 4
0
        /// <summary>
        ///     Persists changes to LuceneController & SqlController without running validation checks
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocSubmittedBy"></param>
        /// <param name="RelayUrl"></param>
        /// <param name="SubmittedDate"></param>
        /// <param name="DocKeys"></param>
        /// <param name="DocTitle"></param>
        /// <returns></returns>
        public LightDoc Import(string DocData, string DocSubmittedBy = null, string RelayUrl = null, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null)
        {
            //DocData = PIRewrite(DocData, DocStatus, SubmittedDate, DocKeys, DocTitle);
            LightDoc _LightDoc = LuceneController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle);

            //when not in debug mode perform SQL operations on another thread since they seem to be costly
            SqlController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle);
            if (_LightDoc.DocTypeName == "DOCREV")
            {
                BaseDoc _BaseDoc = DocInterpreter.Instance.Create(_LightDoc.GetTargetDocName());
                _BaseDoc.DocIdKeys = new Dictionary <string, string> {
                    { "DefaultAsOfDate", DateTime.UtcNow.ToShortDateString() }
                };
                SqlController.Submit(_BaseDoc.GetDocData(), "*****@*****.**");
            }
            return(_LightDoc);
        }
Esempio n. 5
0
 public BaseDoc Create(out string DocSrc, Dictionary <string, string> DocKeys, BaseDoc Doc, string RelayUrl = null)
 {
     return((BaseDoc)ServiceController.Instance.Create(out DocSrc, Doc, DocKeys, RelayUrl));
 }