示例#1
0
        /// <summary>
        /// <c>ComputeHashSP07</c>
        /// calls <c>ComputeHashWithoutSalt</c> function to calculate hash value of string
        /// </summary>
        /// <param name="FileBytes"></param>
        /// <param name="msgbody"></param>
        public static void ComputeHashSP07(byte[] FileBytes, string msgbody)
        {
            try
            {

                Stream msgstream = new MemoryStream(FileBytes);

                Utility.OutlookStorage.Message message = new OutlookStorage.Message(msgstream);

                string tstval = message.BCCTest;

                string to = "";
                to = message.ReceivedByEmail;
                string ccs = "";

                foreach (OutlookStorage.Recipient r in message.Recipients)
                {
                    if (r.Type == OutlookStorage.RecipientType.CC)
                    {
                        ccs += r.DisplayName;
                    }
                    else
                    {
                        if (r.Type == OutlookStorage.RecipientType.To)
                        {
                            to = r.DisplayName;
                        }
                    }
                }

                string subject = message.Subject;
                HtmlFromRtf htmlfromrtf = new HtmlFromRtf();
                string strmessagebody = htmlfromrtf.GetRefinedHtmlFromRtf(message.BodyRTF); // msgbody;
                //try
                //{
                //    System.Windows.Forms.RichTextBox rt = new System.Windows.Forms.RichTextBox();
                //    rt.Rtf = message.BodyRTF;
                //    strmessagebody = rt.Text;
                //}
                //catch (Exception ex)
                //{
                //    strmessagebody = message.BodyText;
                //}
                //try
                //{
                //    while (strmessagebody.IndexOf("\r\n") != -1)
                //    {
                //        strmessagebody = strmessagebody.Remove(strmessagebody.IndexOf("\r\n"), 2);
                //    }

                //}
                //catch (Exception)
                //{

                //}

                string strtime = "";
                string msgdate = message.SentDate;
                if (string.IsNullOrEmpty(msgdate))
                {
                    msgdate = msgbody;
                }
                try
                {
                    msgdate = Convert.ToDateTime(msgdate).ToString("M/d/yyyy hh:mm tt zz");
                    strtime = Convert.ToDateTime(msgdate).ToString("hh:mm tt");
                }
                catch (Exception)
                {

                }
                Log("Hashing Log 10:", true);

                string strfinalvalue = to + ccs + subject + strmessagebody;// +strtime;

                Log("tobehash" + strfinalvalue, false);

                if (!string.IsNullOrEmpty(strfinalvalue))
                {
                    string v = HashingClass.ComputeHashWithoutSalt(strfinalvalue, "MD5");
                    HashingClass.Hashedemailbody = v;

                }

                if (!string.IsNullOrEmpty(message.Subject))
                {
                    HashingClass.Mailsubject = message.Subject;
                }
                else
                {
                    try
                    {
                        HashingClass.Mailsubject = message.Subject;
                    }
                    catch (Exception)
                    {

                    }
                }

                if (message.SentDate != "")
                {
                    HashingClass.Modifieddate = msgdate;// message.SentDate;

                }
                else
                {
                    if (message.SentDate != null)
                    {
                        HashingClass.Modifieddate = msgdate;// message.SentDate;
                    }
                }

            }
            catch (Exception)
            {
            }
        }
示例#2
0
        /// <summary>
        /// <c>uploadFilestoLibraryUsingClientOM</c> member function
        /// upload file to sharepoint Document Library using Client object model
        /// </summary>
        /// <param name="udataitem"></param>
        /// <param name="cmproperty"></param>
        /// <returns></returns>
        public static bool uploadFilestoLibraryUsingClientOM(SharePoint_Link.UserModule.UploadItemsData udataitem, CommonProperties cmproperty)
        {
            bool result = false;
            try
            {

                CommonProperties cmproperties = new CommonProperties();
                string tempFilePath = UserLogManagerUtility.RootDirectory + "\\" + udataitem.UploadFileName;// +udataitem.UploadFileExtension;

                if (System.IO.File.Exists(tempFilePath))
                {
                    System.IO.File.Delete(tempFilePath);
                }

                FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.ReadWrite);

                //////// out look storage//////////

                try
                {
                    if (udataitem.UploadType == TypeOfUploading.Mail)
                    {

                        Stream msgstream = new MemoryStream(cmproperty.FileBytes);

                        Utility.OutlookStorage.Message message = new OutlookStorage.Message(msgstream);
                        if (!string.IsNullOrEmpty(message.BodyText))
                        {
                            //  HashingClass.Hashedemailbody = HashingClass.ComputeHashWithoutSalt(message.BodyText, "MD5");

                        }
                        if (!string.IsNullOrEmpty(message.Subject))
                        {
                            HashingClass.Mailsubject = message.Subject;

                        }
                        if (message.SentDate != "")
                        {
                            HashingClass.Modifieddate = message.SentDate;

                        }

                    }
                }
                catch (Exception)
                {

                }

                //////////End of outlook storage////

                if (cmproperty.FileBytes != null)
                {

                    BinaryWriter bw = new BinaryWriter(fs);
                    bw.Write(cmproperty.FileBytes);
                    bw.Close();

                }

                ///updated new 6jan//////
                string strsitepath = cmproperty.LibSite;

                string strleftpart = "/";
                int firstindex = -1;
                int secondindex = -1;
                firstindex = strsitepath.IndexOf(@"//");
                try
                {

                    if (firstindex != -1)
                    {
                        if (strsitepath.Length >= (firstindex + 3))
                        {
                            secondindex = strsitepath.IndexOf(@"/", firstindex + 3);
                            if (secondindex != -1)
                            {
                                if (strsitepath.Length >= (secondindex + 1))
                                {
                                    strleftpart = strleftpart + strsitepath.Substring(secondindex + 1);
                                    if (strsitepath.Length > (secondindex + 1))
                                    {
                                        strsitepath = strsitepath.Remove(secondindex + 1);
                                    }

                                    cmproperty.LibSite = strsitepath;
                                }

                            }

                        }

                    }
                }
                catch (Exception)
                {
                }

                string pth = strleftpart + cmproperty.UploadDocLibraryName + "/" + udataitem.UploadFileName;

                // end of new///

                Microsoft.SharePoint.Client.ClientContext ct = new ClientContext(cmproperty.LibSite);

                ct.Credentials = ListWebClass.GetCredential(cmproperty);

                using (FileStream filestream = new FileStream(tempFilePath, FileMode.Open))
                {

                        Microsoft.SharePoint.Client.File.SaveBinaryDirect(ct, pth, filestream, true);

                };

                result = true;

                /////
                // Get ID of Uploaded File
                FileID = GetFileID(udataitem, cmproperty, strleftpart);
                HashingClass.Mailsubject = "";
                HashingClass.Modifieddate = "";
                HashingClass.Hashedemailbody = "";

                ////

                ////////////

                /////////////

                if (System.IO.File.Exists(tempFilePath))
                {
                    System.IO.File.Delete(tempFilePath);
                }

            }
            catch (Exception ex)
            {
                string errmessage = ex.Message.ToString();

                SharePoint_Link.frmUploadItemsList.UpLoadErrorMessage = errmessage;// ex.InnerException.Message.ToString();
                result = false;

            }

            return result;
        }