public GXBaseCollection(GXBaseCollection <T> value)
 {
     foreach (T item in value)
     {
         Add(item);
     }
 }
        public virtual object Clone()
        {
            GXBaseCollection <T> collection = new GXBaseCollection <T>();

            foreach (T item in this)
            {
                collection.Add(item);
            }
            return(collection);
        }
 public bool FromXmlFile(GxFile file, GXBaseCollection <SdtMessages_Message> Messages, string sName, string sNameSpace)
 {
     if (GXUtil.CheckFile(file, Messages))
     {
         return(FromXml(file.ReadAllText(string.Empty), Messages, sName, sNameSpace));
     }
     else
     {
         return(false);
     }
 }
 public bool FromJSonFile(GxFile file, GXBaseCollection <SdtMessages_Message> Messages)
 {
     if (file != null && file.Exists())
     {
         string s = file.ReadAllText(string.Empty);
         return(FromJSonString(s, Messages));
     }
     else
     {
         GXUtil.ErrorToMessages("FromJSon Error", "File does not exist", Messages);
         return(false);
     }
 }
        public bool FromJSonString(string s, GXBaseCollection <SdtMessages_Message> Messages)
        {
            _jsonArr = JSONHelper.ReadJSON <JArray>(s, Messages);
            bool result = _jsonArr != null;

            try
            {
                FromJSONObject((JArray)jsonArr);
                return(result);
            }
            catch (Exception ex)
            {
                GXUtil.ErrorToMessages("FromJson Error", ex, Messages);
                return(false);
            }
        }
        public static string MessagesToString(GXBaseCollection <SdtMessages_Message> messages)
        {
            StringBuilder str = new StringBuilder();

            foreach (SdtMessages_Message msg in messages)
            {
                string msgType;
                switch (msg.gxTpr_Type)
                {
                case (int)MessageTypes.Warning: msgType = "Warning"; break;

                case (int)MessageTypes.Error: msgType = "Error"; break;

                default: goto case (int)MessageTypes.Warning;
                }
                str.AppendFormat("{0}:{3}  Code: {1}{3}  Description: {2}{3}", msgType, msg.gxTpr_Id, msg.gxTpr_Description, StringUtil.NewLine());
            }
            return(str.ToString());
        }
Beispiel #7
0
 public static T ReadJavascriptJSON <T>(string json, GXBaseCollection <SdtMessages_Message> Messages = null) where T : class
 {
     try
     {
         if (!string.IsNullOrEmpty(json))
         {
             return(GXJsonSerializer.Instance.ReadJSON <T>(json));
         }
         else
         {
             GXUtil.ErrorToMessages("FromJson Error", "Empty json", Messages);
             return(default(T));
         }
     }
     catch (Exception ex)
     {
         GXUtil.ErrorToMessages("FromJson Error", ex, Messages);
         GXLogging.Error(log, "FromJsonError ", ex);
         return(default(T));
     }
 }
 public static T ReadJSON <T>(string json, GXBaseCollection <SdtMessages_Message> Messages = null) where T : class
 {
     try
     {
         if (!string.IsNullOrEmpty(json))
         {
             Jayrock.Json.JsonTextReader reader = new Jayrock.Json.JsonTextReader(new StringReader(json));
             return((T)reader.DeserializeNext());
         }
         else
         {
             GXUtil.ErrorToMessages("FromJson Error", "Empty json", Messages);
             return(default(T));
         }
     }
     catch (Exception ex)
     {
         GXUtil.ErrorToMessages("FromJson Error", ex, Messages);
         GXLogging.Error(log, "FromJsonError ", ex);
         return(default(T));
     }
 }
Beispiel #9
0
        public GXBaseCollection <SdtMessages_Message> GetMessages()
        {
            short item = 1;
            GXBaseCollection <SdtMessages_Message> msgs = new GXBaseCollection <SdtMessages_Message>(context, "Messages.Message", "Genexus");
            SdtMessages_Message m1;
            IGxSilentTrn        trn = getTransaction();

            if (trn != null)
            {
                msglist msgList = trn.GetMessages();
                while (item <= msgList.ItemCount)
                {
                    m1                   = new SdtMessages_Message(context);
                    m1.gxTpr_Id          = msgList.getItemValue(item);
                    m1.gxTpr_Description = msgList.getItemText(item);
                    m1.gxTpr_Type        = msgList.getItemType(item);
                    msgs.Add(m1, 0);
                    item = (short)(item + 1);
                }
            }
            return(msgs);
        }
Beispiel #10
0
 public bool Get(string storageobjectfullname, GxFile externalFile, GXBaseCollection <SdtMessages_Message> messages)
 {
     try
     {
         ValidProvider();
         string url = provider.Get(storageobjectfullname, GxFileType.Public, 0);
         if (String.IsNullOrEmpty(url))
         {
             GXUtil.ErrorToMessages("Get Error", "File doesn't exists", messages);
             return(false);
         }
         else
         {
             externalFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider);
             return(true);
         }
     }
     catch (Exception ex)
     {
         StorageMessages(ex, messages);
         return(false);
     }
 }
        public virtual bool FromXml(string s, GXBaseCollection <SdtMessages_Message> Messages, string sName, string sNamespace)
        {
            try
            {
                if (!string.IsNullOrEmpty(s))
                {
                    base.Clear();
                    GXBaseCollection <T> deserialized = GXXmlSerializer.Deserialize <GXBaseCollection <T> >(this.GetType(), s, sName, sNamespace, out List <string> serializationErrors);
                    GXXmlSerializer.SetSoapError(context, serializationErrors);
                    if (deserialized != null)
                    {
                        foreach (T item in deserialized)
                        {
                            item.context = context;
                            Add(item);
                        }
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                GXLogging.Error(log, "FromXml error", ex);

                context.nSOAPErr = -20006;
                GXXmlSerializer.SetSoapError(context, string.Format("Error reading {0}", this.GetType()));
                GXXmlSerializer.SetSoapError(context, ex.Message);
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    GXXmlSerializer.SetSoapError(context, ex.Message);
                }
                GXUtil.ErrorToMessages("FromXML Error", ex, Messages);
                return(false);
            }
        }
Beispiel #12
0
 protected void StorageMessages(Exception ex, GXBaseCollection <SdtMessages_Message> messages)
 {
     if (messages != null && ex != null)
     {
         SdtMessages_Message msg = new SdtMessages_Message();
         if (provider != null && provider.GetMessageFromException(ex, msg))
         {
             msg.gxTpr_Type = 1;
             StringBuilder str = new StringBuilder();
             str.Append(ex.Message);
             while (ex.InnerException != null)
             {
                 str.Append(ex.InnerException.Message);
                 ex = ex.InnerException;
             }
             msg.gxTpr_Description = str.ToString();
             messages.Add(msg);
         }
         else
         {
             GXUtil.ErrorToMessages("Storage Error", ex, messages);
         }
     }
 }
Beispiel #13
0
        public bool DownloadPrivate(string storageobjectfullname, GxFile localFile, GXBaseCollection <SdtMessages_Message> messages)
        {
            try
            {
                ValidProvider();
                string destFileName;

                if (Path.IsPathRooted(localFile.GetAbsoluteName()))
                {
                    destFileName = localFile.GetAbsoluteName();
                }
                else
                {
                    destFileName = Path.Combine(GxContext.StaticPhysicalPath(), localFile.Source);
                }
                provider.Download(storageobjectfullname, destFileName, GxFileType.Private);
                return(true);
            }
            catch (Exception ex)
            {
                StorageMessages(ex, messages);
                return(false);
            }
        }
Beispiel #14
0
 public bool GetDirectory(string directoryFullName, GxDirectory externalDirectory, GXBaseCollection <SdtMessages_Message> messages)
 {
     try
     {
         ValidProvider();
         string path = provider.GetDirectory(directoryFullName);
         if (String.IsNullOrEmpty(path))
         {
             GXUtil.ErrorToMessages("Get Error", "Directory doesn't exists", messages);
             return(false);
         }
         else
         {
             externalDirectory.DirectoryInfo = new GxExternalDirectoryInfo(directoryFullName, path, provider);
             return(true);
         }
     }
     catch (Exception ex)
     {
         StorageMessages(ex, messages);
         return(false);
     }
 }
Beispiel #15
0
 public bool UploadPrivate(string filefullpath, string storageobjectfullname, GxFile uploadedFile, GXBaseCollection <SdtMessages_Message> messages)
 {
     try
     {
         ValidProvider();
         if (String.IsNullOrEmpty(storageobjectfullname))
         {
             storageobjectfullname = Path.GetFileName(filefullpath);
         }
         string url = provider.Upload(filefullpath, storageobjectfullname, GxFileType.Private);
         uploadedFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider);
         return(true);
     }
     catch (Exception ex)
     {
         StorageMessages(ex, messages);
         return(false);
     }
 }