Changeset 8427


Ignore:
Timestamp:
Oct 21, 2019, 1:31:24 PM (2 years ago)
Author:
kopal
Message:
  • CrypToolStoreLib:

improved server layer logging (by also logging stacktraces of exceptions)
type-cast fix in GetPublishedResources()-method of database layer

Location:
trunk/LibSource/CrypToolStoreLib/CrypToolStoreLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LibSource/CrypToolStoreLib/CrypToolStoreLib/Database/Database.cs

    r8420 r8427  
    11871187
    11881188            foreach (var entry in resultset)
    1189             {
     1189            {               
    11901190                Resource resource = new Resource();
    1191                 resource.Id = (int)entry["id"];
     1191                resource.Id = Int32.Parse(entry["id"].ToString());
    11921192                resource.Username = (string)entry["username"];
    11931193                resource.Name = (string)entry["name"];
     
    11961196                ResourceData resourceData = new ResourceData();
    11971197                resourceData.ResourceId = resource.Id;
    1198                 resourceData.ResourceVersion = (int)entry["resourceversion"];
     1198                resourceData.ResourceVersion = Int32.Parse(entry["resourceversion"].ToString());
    11991199                resourceData.PublishState = (string)entry["publishstate"];
    12001200
     
    12021202                resourceAndResourceData.Resource = resource;
    12031203                resourceAndResourceData.ResourceData = resourceData;
    1204                 resourcesAndResourceDatas.Add(resourceAndResourceData);
     1204                resourcesAndResourceDatas.Add(resourceAndResourceData);               
    12051205            }
    12061206            return resourcesAndResourceDatas;
  • trunk/LibSource/CrypToolStoreLib/CrypToolStoreLib/Server/Server.cs

    r8419 r8427  
    129129                                {
    130130                                    logger.LogText(String.Format("Exception during handling of client from IP/Port={0} : {1}", client.Client.RemoteEndPoint, ex.Message), this, Logtype.Error);
     131                                    logger.LogException(ex, this, Logtype.Error);
    131132                                }                           
    132133                                UnregisterClientHandler(handler);
     
    135136                            {
    136137                                logger.LogText(String.Format("Exception during handling of client from IP/Port={0} : {1}", client.Client.RemoteEndPoint, ex.Message), this, Logtype.Error);
     138                                logger.LogException(ex, this, Logtype.Error);
    137139                            }   
    138140                        });                       
     
    145147                        {
    146148                            logger.LogText(String.Format("Exception in ListenThread: {0}", ex.Message), this, Logtype.Error);
     149                            logger.LogException(ex, this, Logtype.Error);
    147150                        }
    148151                    }
     
    155158                {
    156159                    logger.LogText(String.Format("Exception in ListenThread: {0}", ex.Message), this, Logtype.Error);
     160                    logger.LogException(ex, this, Logtype.Error);
    157161                }
    158162            }
     
    225229            {
    226230                logger.LogText(String.Format("Exception during stopping of server: {0}", ex.Message), this, Logtype.Error);
     231                logger.LogException(ex, this, Logtype.Error);
    227232            }
    228233        }
     
    298303                {
    299304                    Logger.LogText(String.Format("Exception during HandleClient: {0}", ex.Message), this, Logtype.Error);
     305                    Logger.LogException(ex, this, Logtype.Error);
    300306                    return;
    301307                }
     
    643649                response.ModifiedDeveloper = false;
    644650                Logger.LogText(String.Format("User {0} tried to create a new developer. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     651                Logger.LogException(ex, this, Logtype.Error);
    645652                response.Message = "Exception during creation of new developer";
    646653                SendMessage(response, sslStream);       
     
    698705                response.ModifiedDeveloper = false;
    699706                Logger.LogText(String.Format("User {0} tried to update an existing developer. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     707                Logger.LogException(ex, this, Logtype.Error);
    700708                response.Message = "Exception during update of existing developer";
    701709                SendMessage(response, sslStream);
     
    741749                response.ModifiedDeveloper = false;
    742750                Logger.LogText(String.Format("User {0} tried to delete an existing developer. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     751                Logger.LogException(ex, this, Logtype.Error);
    743752                response.Message = "Exception during deletion of existing developer";
    744753                SendMessage(response, sslStream);
     
    796805                response.DeveloperExists = false;
    797806                Logger.LogText(String.Format("User {0} tried to get an existing developer. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     807                Logger.LogException(ex, this, Logtype.Error);
    798808                response.Message = "Exception during request of existing developer:";
    799809                SendMessage(response, sslStream);
     
    841851                response.AllowedToViewList = false;
    842852                Logger.LogText(String.Format("User {0} tried to get a developer list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     853                Logger.LogException(ex, this, Logtype.Error);
    843854                response.Message = "Exception during request of developer list";
    844855                SendMessage(response, sslStream);
     
    884895                response.ModifiedPlugin = false;
    885896                Logger.LogText(String.Format("User {0} tried to create a new plugin. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     897                Logger.LogException(ex, this, Logtype.Error);
    886898                response.Message = "Exception during creation of new plugin";
    887899                SendMessage(response, sslStream);
     
    960972                response.ModifiedPlugin = false;
    961973                Logger.LogText(String.Format("User {0} tried to update an existing plugin. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     974                Logger.LogException(ex, this, Logtype.Error);
    962975                response.Message = "Exception during update of existing plugin";
    963976                SendMessage(response, sslStream);
     
    10261039                response.ModifiedPlugin = false;
    10271040                Logger.LogText(String.Format("User {0} tried to delete an existing plugin={1}. But an exception occured: {2}", Username, deletePluginMessage.Plugin.Id, ex.Message), this, Logtype.Error);
     1041                Logger.LogException(ex, this, Logtype.Error);
    10281042                response.Message = "Exception during delete of existing plugin";
    10291043                SendMessage(response, sslStream);
     
    10801094                ResponsePluginMessage response = new ResponsePluginMessage();
    10811095                Logger.LogText(String.Format("User {0} tried to get an existing plugin. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1096                Logger.LogException(ex, this, Logtype.Error);
    10821097                response.Message = "Exception during request of existing plugin";
    10831098                SendMessage(response, sslStream);
     
    11141129                ResponsePluginMessage response = new ResponsePluginMessage();
    11151130                Logger.LogText(String.Format("User {0} tried to get a plugin list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1131                Logger.LogException(ex, this, Logtype.Error);
    11161132                response.Message = "Exception during request of source list";
    11171133                SendMessage(response, sslStream);
     
    11701186                ResponsePublishedPluginListMessage response = new ResponsePublishedPluginListMessage();
    11711187                Logger.LogText(String.Format("User {0} tried to get a published plugin list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1188                Logger.LogException(ex, this, Logtype.Error);
    11721189                response.Message = "Exception during request of source list";
    11731190                SendMessage(response, sslStream);
     
    12131230                ResponsePublishedPluginMessage response = new ResponsePublishedPluginMessage();
    12141231                Logger.LogText(String.Format("User {0} tried to get a published plugin. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1232                Logger.LogException(ex, this, Logtype.Error);
    12151233                response.Message = "Exception during request of published plugin";
    12161234                SendMessage(response, sslStream);
     
    12821300                response.ModifiedSource = false;
    12831301                Logger.LogText(String.Format("User {0} tried to create a new source. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1302                Logger.LogException(ex, this, Logtype.Error);
    12841303                response.Message = "Exception during creation of new source";
    12851304                SendMessage(response, sslStream);
     
    13491368                response.ModifiedSource = false;
    13501369                Logger.LogText(String.Format("User {0} tried to update an existing source. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1370                Logger.LogException(ex, this, Logtype.Error);
    13511371                response.Message = "Exception during update of existing source";
    13521372                SendMessage(response, sslStream);
     
    14361456                response.ModifiedSource = false;
    14371457                Logger.LogText(String.Format("User {0} tried to update the publish state of an existing source. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1458                Logger.LogException(ex, this, Logtype.Error);
    14381459                response.Message = "Exception during update of publish state of existing source";
    14391460                SendMessage(response, sslStream);
     
    15191540                response.ModifiedSource = false;
    15201541                Logger.LogText(String.Format("User {0} tried to delete an existing source={1}-{2}. But an exception occured: {3}", Username, deleteSourceMessage.Source.PluginId, deleteSourceMessage.Source.PluginVersion, ex.Message), this, Logtype.Error);
     1542                Logger.LogException(ex, this, Logtype.Error);
    15211543                response.Message = "Exception during delete of existing source";
    15221544                SendMessage(response, sslStream);
     
    15751597                ResponseSourceMessage response = new ResponseSourceMessage();
    15761598                Logger.LogText(String.Format("User {0} tried to get an existing source={1}-{2}. But an exception occured: {3}", Username, requestSourceMessage.PluginId, requestSourceMessage.PluginVersion, ex.Message), this, Logtype.Error);
     1599                Logger.LogException(ex, this, Logtype.Error);
    15771600                response.Message = "Exception during request of existing source";
    15781601                SendMessage(response, sslStream);
     
    16421665                ResponseSourceListMessage response = new ResponseSourceListMessage();
    16431666                Logger.LogText(String.Format("User {0} tried to get a source list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1667                Logger.LogException(ex, this, Logtype.Error);
    16441668                response.Message = "Exception during request of source list";
    16451669                SendMessage(response, sslStream);
     
    16851709                response.ModifiedResource = false;
    16861710                Logger.LogText(String.Format("User {0} tried to create a new resource. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1711                Logger.LogException(ex, this, Logtype.Error);
    16871712                response.Message = "Exception during creation of new resource";
    16881713                SendMessage(response, sslStream);
     
    17521777                response.ModifiedResource = false;
    17531778                Logger.LogText(String.Format("User {0} tried to update an existing resource={1}. But an exception occured: {2}", Username, resource.Id, ex.Message), this, Logtype.Error);
     1779                Logger.LogException(ex, this, Logtype.Error);
    17541780                response.Message = "Exception during update of existing resource";
    17551781                SendMessage(response, sslStream);
     
    17961822                response.ModifiedResource = false;
    17971823                response.Message = "Unauthorized to delete that resource";
    1798                 Logger.LogText(String.Format("Unauthorized user {0} tried to delete resource={1} from IP={2}", Username, deleteResourceMessage.Resource.Id, IPAddress), this, Logtype.Warning);
     1824                Logger.LogText(String.Format("Unauthorized user {0} tried to delete resource={1} from IP={2}", Username, deleteResourceMessage.Resource.Id, IPAddress), this, Logtype.Warning);               
    17991825                SendMessage(response, sslStream);
    18001826                return;
     
    18181844                response.ModifiedResource = false;
    18191845                Logger.LogText(String.Format("User {0} tried to delete an existing resource={1}. But an exception occured: {2}", Username, deleteResourceMessage.Resource.Id, ex.Message), this, Logtype.Error);
     1846                Logger.LogException(ex, this, Logtype.Error);
    18201847                response.Message = "Exception during delete of existing resource";
    18211848                SendMessage(response, sslStream);
     
    18731900                ResponseResourceMessage response = new ResponseResourceMessage();
    18741901                Logger.LogText(String.Format("User {0} tried to get an existing resource. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1902                Logger.LogException(ex, this, Logtype.Error);
    18751903                response.Message = "Exception during request of existing resource";
    18761904                SendMessage(response, sslStream);
     
    19071935                ResponseResourceMessage response = new ResponseResourceMessage();
    19081936                Logger.LogText(String.Format("User {0} tried to get a resource list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1937                Logger.LogException(ex, this, Logtype.Error);
    19091938                response.Message = "Exception during request of resource list";
    19101939                SendMessage(response, sslStream);
     
    19631992                ResponsePublishedResourceListMessage response = new ResponsePublishedResourceListMessage();
    19641993                Logger.LogText(String.Format("User {0} tried to get a published resource list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     1994                Logger.LogException(ex, this, Logtype.Error);
    19651995                response.Message = "Exception during request of source list";
    19661996                SendMessage(response, sslStream);
     
    20062036                ResponsePublishedResourceMessage response = new ResponsePublishedResourceMessage();
    20072037                Logger.LogText(String.Format("User {0} tried to get a published resource. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2038                Logger.LogException(ex, this, Logtype.Error);
    20082039                response.Message = "Exception during request of published resource";
    20092040                SendMessage(response, sslStream);
     
    20752106                response.ModifiedResourceData = false;
    20762107                Logger.LogText(String.Format("User {0} tried to create a new resource data={1}-{2}. But an exception occured: {3}", Username, createNewResourceDataMessage.ResourceData.ResourceId, createNewResourceDataMessage.ResourceData.ResourceVersion, ex.Message), this, Logtype.Error);
     2108                Logger.LogException(ex, this, Logtype.Error);
    20772109                response.Message = "Exception during creation of new resource data";
    20782110                SendMessage(response, sslStream);
     
    21422174                response.ModifiedResourceData = false;
    21432175                Logger.LogText(String.Format("User {0} tried to update an existing resource data={1}-{2}. But an exception occured: {3}", Username, updateResourceDataMessage.ResourceData.ResourceId, updateResourceDataMessage.ResourceData.ResourceVersion, ex.Message), this, Logtype.Error);
     2176                Logger.LogException(ex, this, Logtype.Error);
    21442177                response.Message = "Exception during update of existing resource data";
    21452178                SendMessage(response, sslStream);
     
    22292262                response.ModifiedSource = false;
    22302263                Logger.LogText(String.Format("User {0} tried to update the publish state of an existing source. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2264                Logger.LogException(ex, this, Logtype.Error);
    22312265                response.Message = "Exception during update of publish state of existing source";
    22322266                SendMessage(response, sslStream);
    22332267            }
    22342268        }
    2235 
    2236 
    22372269
    22382270        /// <summary>
     
    22852317            try
    22862318            {
     2319                //1. delete files in file system
     2320                string filename = Constants.CLIENTHANDLER_RESOURCEDATA_FOLDER + Path.DirectorySeparatorChar + "ResourceData-" + deleteResourceDataMessage.ResourceData.ResourceId + "-" + deleteResourceDataMessage.ResourceData.ResourceVersion + ".bin";               
     2321                if (File.Exists(filename))
     2322                {
     2323                    Logger.LogText(String.Format("Deleting resource data file: {0}", filename), this, Logtype.Info);
     2324                    File.Delete(filename);
     2325                    Logger.LogText(String.Format("Deleted resource data file: {0}", filename), this, Logtype.Info);
     2326                }
     2327
     2328                //2. delete entry in database
    22872329                Database.DeleteResourceData(deleteResourceDataMessage.ResourceData.ResourceId, deleteResourceDataMessage.ResourceData.ResourceVersion);
    22882330                Logger.LogText(String.Format("User {0} deleted existing resource data={1}-{2} in database", Username, deleteResourceDataMessage.ResourceData.ResourceId, deleteResourceDataMessage.ResourceData.ResourceVersion), this, Logtype.Info);
     
    22982340                response.ModifiedResourceData = false;
    22992341                Logger.LogText(String.Format("User {0} tried to delete an existing resource data={1}-{2}. But an exception occured: {3}", Username, deleteResourceDataMessage.ResourceData.ResourceId, deleteResourceDataMessage.ResourceData.ResourceVersion, ex.Message), this, Logtype.Error);
     2342                Logger.LogException(ex, this, Logtype.Error);
    23002343                response.Message = "Exception during delete of existing resource data";
    23012344                SendMessage(response, sslStream);
     
    23542397                ResponseResourceDataMessage response = new ResponseResourceDataMessage();
    23552398                Logger.LogText(String.Format("User {0} tried to get an existing resource data={1}-{2}. But an exception occured: {3}", Username, requestResourceDataMessage.ResourceId, requestResourceDataMessage.ResourceVersion, ex.Message), this, Logtype.Error);
     2399                Logger.LogException(ex, this, Logtype.Error);
    23562400                response.Message = "Exception during request of existing resource data";
    23572401                SendMessage(response, sslStream);
     
    24102454                ResponseResourceDataListMessage response = new ResponseResourceDataListMessage();
    24112455                Logger.LogText(String.Format("User {0} tried to get a resource data list. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2456                Logger.LogException(ex, this, Logtype.Error);
    24122457                response.Message = "Exception during request of resource data list";
    24132458                SendMessage(response, sslStream);
     
    25472592                response.Success = false;
    25482593                Logger.LogText(String.Format("User {0} tried to upload a source zipfile. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2594                Logger.LogException(ex, this, Logtype.Error);
    25492595                response.Message = "Exception during upload of source zipfile";
    25502596                SendMessage(response, sslStream);
     
    26952741                response.Success = false;
    26962742                Logger.LogText(String.Format("User {0} tried to upload a zipfile. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2743                Logger.LogException(ex, this, Logtype.Error);
    26972744                response.Message = "Exception during upload of zipfile";
    26982745                SendMessage(response, sslStream);
     
    28452892                response.Success = false;
    28462893                Logger.LogText(String.Format("User {0} tried to upload a resourcedata file. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     2894                Logger.LogException(ex, this, Logtype.Error);
    28472895                response.Message = "Exception during upload of resourcedata file";
    28482896                SendMessage(response, sslStream);
     
    30143062                response.Success = false;
    30153063                Logger.LogText(String.Format("User {0} tried to download a source zipfile. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     3064                Logger.LogException(ex, this, Logtype.Error);
    30163065                response.Message = "Exception during download of source zipfile";
    30173066                SendMessage(response, sslStream);
     
    31743223                response.Success = false;
    31753224                Logger.LogText(String.Format("User {0} tried to download an assembly zipfile. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     3225                Logger.LogException(ex, this, Logtype.Error);
    31763226                response.Message = "Exception during download of assembly zipfile";
    31773227                SendMessage(response, sslStream);
     
    33323382                response.Success = false;
    33333383                Logger.LogText(String.Format("User {0} tried to download an resourcedata file. But an exception occured: {1}", Username, ex.Message), this, Logtype.Error);
     3384                Logger.LogException(ex, this, Logtype.Error);
    33343385                response.Message = "Exception during download of resourcedata file";
    33353386                SendMessage(response, sslStream);
Note: See TracChangeset for help on using the changeset viewer.