• Santosh Uppala
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi All,
I am trying to convert c# ticks mehtod of datetime in apex. Document says that getime() method will work as ticks method of C#, but when i try to compare both results its coming different. So can any who is familiar with it help me on it?
Here is the code.
C#:
long time = DateTime.Now.Ticks;
Console.WriteLine(time);
O/P : 636297691874640148

Apex Code:
DateTime dt = system.Now();
 long ticks = dt.getTime(); 
O/p : 1494165245354

As you can see above there is a difference in the output. So please let me know where i am doing a mistake.

Thanks in Advance !!
Hi all,

I am facing issues while converting C# code to apex. Below is the C# code:

using System.IO;
using System.Security.Cryptography;
using System.Text;

        {
            //REST API keys for encryption
            const string key = "a678-78js-986s-iujk-8769";
            const string IV = "ohjk-0987-6h7j-12sg-678j";

            //PlainTest of credentials along with DT in UTC for auth
            string plainText = username + Environment.NewLine +
                               password + Environment.NewLine +
                               DateTime.UtcNow.Ticks;

            //Check the input
            if (plainText == null || plainText.Length == 0)
                throw new ArgumentNullException("plaintext", "plaintext cannot be blank.");
            if (key == null || key.Length == 0)
                throw new ArgumentNullException("key", "key cannot be blank.");

            //Get the input as bytes
            byte[] buffPlain = Encoding.UTF8.GetBytes(plainText);

            //Create and setup the crypto objects
            RijndaelManaged crypt = new RijndaelManaged();
            MD5CryptoServiceProvider hashMD5 = new MD5CryptoServiceProvider();
            crypt.Key = hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
            crypt.IV = hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(IV));
            crypt.Mode = CipherMode.CBC;

            //Create the memory streams
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms, crypt.CreateEncryptor(), CryptoStreamMode.Write);

            //Write the data through the crypto stream into the memory stream
            try
            {
                cs.Write(buffPlain, 0, buffPlain.Length);
                cs.FlushFinalBlock();
            }
            finally
            {
                //Close the streams
                cs.Close();
                ms.Close();

                //Clear the crypto objects;
                hashMD5.Clear();
                crypt.Clear();
            }

            //Get the encrypted bytes
            byte[] buffEnc = ms.ToArray();
            StringBuilder ret = new StringBuilder();

            //Convert the bytes to hex with a length of 2
            foreach (byte b in buffEnc)
            {
                ret.AppendFormat("{0:X2}", b);
            }

            return ret.ToString();
        }
I'm getting the following error when attempting to convert a lead that has a flow scheduled (Process Builder):

"Unable to convert lead that is in use by workflow"

Is there a way to resolve this without manually deleting the scheduled flows?