Exemplo n.º 1
0
        private void CopyAttachments(GxStringCollection fromList, Attachments toList)
        {
            GXLogging.Debug(log, "Copying Attachments");
            char pSep = System.IO.Path.DirectorySeparatorChar;

            if (!attachDir.EndsWith(pSep.ToString()))
            {
                attachDir += pSep.ToString();
            }

            foreach (string attach in fromList)
            {
                string fullFileName = attachDir;
                if (attach.StartsWith(pSep.ToString()))
                {
                    fullFileName += attach.Substring(1);
                }
                else
                {
                    fullFileName += attach;
                }

                try
                {
                    Attachment newAttach = (Attachment)toList.Add(attach, 0, optional, fullFileName);
                    newAttach.ReadFromFile(fullFileName);
                }
                catch (Exception exc)
                {
                    GXLogging.Error(log, "Invalid attachment " + fullFileName, exc);
                    throw new GXMailException("Invalid attachment " + fullFileName, 15);
                }
            }
        }
Exemplo n.º 2
0
        private void CopyAttachments(Attachments fromList, GxStringCollection toList)
        {
            GXLogging.Debug(log, "Copying Attachments");
            int    lastBar  = 0;
            string fileName = "";

            if (string.IsNullOrEmpty(attachDir))
            {
                attachDir = Environment.CurrentDirectory;
            }

            for (int i = 1; i <= fromList.Count; i++)
            {
                Attachment attachment = fromList[i];
                if (!string.IsNullOrEmpty(attachDir))
                {
                    try
                    {
                        fileName = attachment.FileName;
                    }
                    catch (System.Exception exc)
                    {
                        GXLogging.Error(log, "Error reading attachment FileName", exc);
                        continue;
                    }

                    lastBar = fileName.LastIndexOf("\\");
                    if (lastBar != -1)
                    {
                        fileName = fileName.Substring(lastBar + 1);
                    }

                    char pSep = System.IO.Path.DirectorySeparatorChar;
                    if (!attachDir.EndsWith(pSep.ToString()))
                    {
                        attachDir += pSep.ToString();
                    }

                    try
                    {
                        attachment.SaveAsFile(attachDir + fileName);
                    }
                    catch (System.Exception exc)
                    {
                        GXLogging.Error(log, "Could not save attachment", exc);
                        throw new GXMailException("Could not save attachment", 16);
                    }
                }
                lastBar = fileName.LastIndexOf("\\");
                if (lastBar != -1)
                {
                    toList.Add(fileName.Substring(lastBar + 1));
                }
                else
                {
                    toList.Add(fileName);
                }
            }
        }
Exemplo n.º 3
0
 public GXXMLDsig()
 {
     _references     = new List <string>();
     _keyInfoClauses = new GxStringCollection()
     {
         "X509IssuerSerial", "X509SubjectName", "X509Certificate"
     };
     _canonicalizationMethod = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
 }
Exemplo n.º 4
0
 public GxRegexMatch(Match m)
 {
     groups = new GxStringCollection();
     if (m.Success)
     {
         value = m.Groups[0].Value;
         for (int i = 1; i < m.Groups.Count; i++)
         {
             groups.Add(m.Groups[i].Value);
         }
     }
 }
Exemplo n.º 5
0
 public GXMailMessage()
 {
     attachments  = new GxStringCollection();
     to           = new GXMailRecipientCollection();
     cc           = new GXMailRecipientCollection();
     bcc          = new GXMailRecipientCollection();
     replyto      = new GXMailRecipientCollection();
     dateReceived = DateTime.MinValue;
     dateSent     = DateTime.MinValue;
     from         = new GXMailRecipient();
     headers      = new Hashtable();
     htmlText     = "";
     subject      = "";
     text         = "";
 }
Exemplo n.º 6
0
        private void CopyAttachments(GxStringCollection fromList, Attachments toList)
        {
            GXLogging.Debug(log, "Copying Attachments");
            if (string.IsNullOrEmpty(attachDir))
            {
                attachDir = Environment.CurrentDirectory;
            }

            char pSep = System.IO.Path.DirectorySeparatorChar;

            if (!attachDir.EndsWith(pSep.ToString()))
            {
                attachDir += pSep.ToString();
            }

            foreach (string attach in fromList)
            {
                string fullFileName = attachDir;
                if (!Path.IsPathRooted(attach))
                {
                    if (attach.StartsWith(pSep.ToString()))
                    {
                        fullFileName += attach.Substring(1);
                    }
                    else
                    {
                        fullFileName += attach;
                    }
                }
                else
                {
                    fullFileName = attach;
                }

                try
                {
                    Attachment newAttach = toList.Add(fullFileName, optional, optional, attach);
                }
                catch (System.Exception exc)
                {
                    GXLogging.Error(log, "Invalid attachment " + fullFileName, exc);
                    throw new GXMailException("Invalid attachment " + fullFileName, 15);
                }
            }
        }
Exemplo n.º 7
0
        //Convert GxUnknownObjectCollection of Object[] to GxUnknownObjectCollection of GxSimpleCollections
        public GxUnknownObjectCollection TableHashList(GxUnknownObjectCollection tableHashList)
        {
            GxUnknownObjectCollection result = new GxUnknownObjectCollection();

            if (tableHashList != null && tableHashList.Count > 0)
            {
                foreach (object[] list in tableHashList)
                {
                    GxStringCollection tableHash = new GxStringCollection();
                    foreach (string data in list)
                    {
                        tableHash.Add(data);
                    }
                    result.Add(tableHash);
                }
            }
            return(result);
        }
Exemplo n.º 8
0
        public void TestGXIncrementalHash()
        {
            GXUtil.IsWindowsPlatform = false;
            GxStringCollection gxsyncheader = new GxStringCollection();

            gxsyncheader.Add("GXTable");
            gxsyncheader.Add("TiposDeDatos");
            GxStringCollection gxsyncline = new GxStringCollection();

            gxsyncline.Add("A");
            gxsyncline.Add("B");
            GXIncrementalHash gxinchash = new GXIncrementalHash("MD5");

            gxinchash.InitData(gxsyncheader.ToJavascriptSource());
            gxinchash.AppendData(gxsyncline.ToJavascriptSource());
            var gxtablecurrenthash = gxinchash.GetHash();

            Assert.Equal("b97443161c7982869e384d6c068b2f43", gxtablecurrenthash);
        }
Exemplo n.º 9
0
 private void SendAttachments(string sTime, GxStringCollection attachments, string attachDir)
 {
     GXLogging.Debug(log, "Sending attachments, attachments path: " + attachDir);
     try
     {
         int qty = attachments.Count;
         if (qty == 0)
         {
             return;
         }
         SendNL("");
         for (int i = 1; i <= qty; i++)
         {
             SendAttachment(sTime, attachments.Item(i), attachDir);
         }
         SendNL(getNextMessageIdMixed(sTime, true));
     }
     catch (Exception exc)
     {
         GXLogging.Error(log, "Error sending attachments", exc);
         throw new GXMailException(exc.Message, MAIL_ConnectionLost);
     }
 }
        public override void webExecute()
        {
            try
            {
                NameValueCollection parms = context.HttpContext.Request.GetQueryString();

                string gxobj     = parms["object"];
                string attribute = parms["att"];
                string json      = null;

                GxStringCollection gxparms = new GxStringCollection();
                if (parms.Count > 2)
                {
                    for (int i = 2; i < parms.Count; i++)
                    {
                        gxparms.Add(parms[i]);
                    }
                }
                if (!string.IsNullOrEmpty(gxobj) && !string.IsNullOrEmpty(attribute))
                {
                    string nspace;
                    if (!Config.GetValueOf("AppMainNamespace", out nspace))
                    {
                        nspace = "GeneXus.Programs";
                    }
                    GXHttpHandler handler = (GXHttpHandler)ClassLoader.GetInstance(gxobj, nspace + "." + gxobj, null);
                    handler.initialize();

                    json = (string)handler.GetType().InvokeMember("rest_" + attribute.ToUpper(), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, handler, new object[] { gxparms });
                    handler.GetType().InvokeMember("cleanup", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, handler, null);
                }
                if (!string.IsNullOrEmpty(json))
                {
                    if (context.IsMultipartRequest)
                    {
                        this.context.HttpContext.Response.ContentType = MediaTypesNames.TextHtml;
                    }
                    else
                    {
                        this.context.HttpContext.Response.ContentType = MediaTypesNames.ApplicationJson;
                    }
#if NETCORE
                    this.context.HttpContext.Response.Write(json);
#else
                    this.context.HttpContext.Response.Output.WriteLine(json);
#endif
                }
                else
                {
                    this.SendResponseStatus(404, "Resource not found");
                }
            }
            catch (Exception ex)
            {
                SendResponseStatus(500, ex.Message);
                HttpHelper.SetResponseStatusAndJsonError(context.HttpContext, "500", ex.Message);
            }
            finally
            {
                try
                {
                    context.CloseConnections();
                }
                catch
                {
                }
            }
        }
Exemplo n.º 11
0
        private void CopyAttachments(Attachments fromList, GxStringCollection toList)
        {
            GXLogging.Debug(log, "Copying Attachments");
            int    lastBar  = 0;
            string fileName = "";
            Fields fields;
            Field  field;

            for (int i = 1; i <= (int)fromList.Count; i++)
            {
                Attachment attachment = (Attachment)fromList.get_Item(i);
                if (!string.IsNullOrEmpty(attachDir))
                {
                    toList.Add(attachment.Name.ToString());
                    fields = (Fields)attachment.Fields;

                    // Long filename
                    try
                    {                    // 0x3707001E = PR_ATTACH_LONG_FILENAME
                        field    = (Field)fields.get_Item(0x3707001E, optional);
                        fileName = field.Value.ToString();
                    }
                    catch (Exception) {}

                    if (string.IsNullOrEmpty(fileName))
                    {                    // Long filename - UNICODE
                        try
                        {                // 0x3707001E + 1 = PR_ATTACH_LONG_FILENAME
                            field    = (Field)fields.get_Item(0x3707001E + 1, optional);
                            fileName = field.Value.ToString();
                        }
                        catch (Exception) {}
                    }

                    if (string.IsNullOrEmpty(fileName))
                    {                    // Short filename
                        try
                        {                // 0x3704001E = PR_ATTACH_LONG_FILENAME
                            field    = (Field)fields.get_Item(0x3704001E + 1, optional);
                            fileName = field.Value.ToString();
                        }
                        catch (Exception) {}
                    }

                    if (string.IsNullOrEmpty(fileName))
                    {                    // Short filename - UNICODE
                        try
                        {                // 0x3704001E + 1 = PR_ATTACH_LONG_FILENAME
                            field    = (Field)fields.get_Item(0x3704001E + 1, optional);
                            fileName = field.Value.ToString();
                        }
                        catch (Exception) {}
                    }

                    if (string.IsNullOrEmpty(fileName))
                    {
                        fileName = attachment.Source.ToString();
                    }

                    if (string.IsNullOrEmpty(fileName))
                    {
                        fileName = attachment.Name.ToString();
                    }

                    lastBar = fileName.LastIndexOf("\\");
                    if (lastBar != -1)
                    {
                        fileName = fileName.Substring(lastBar + 1);
                    }

                    char pSep = System.IO.Path.DirectorySeparatorChar;
                    if (!attachDir.EndsWith(pSep.ToString()))
                    {
                        attachDir += pSep.ToString();
                    }

                    try
                    {
                        attachment.WriteToFile(attachDir + fileName);
                    }
                    catch (Exception exc)
                    {
                        GXLogging.Error(log, "Could not save attachment", exc);
                        throw new GXMailException("Could not save attachment", 16);
                    }
                }
                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = attachment.Name.ToString();
                }
                lastBar = fileName.LastIndexOf("\\");
                if (lastBar != -1)
                {
                    toList.Add(fileName.Substring(lastBar + 1));
                }
                else
                {
                    toList.Add(fileName);
                }
            }
        }
Exemplo n.º 12
0
 public GxRegexMatch()
 {
     value  = "";
     groups = new GxStringCollection();
 }