public void PostCheck()
        {
            string      xml = OperationContext.Current.RequestContext.RequestMessage.ToString();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);

            CheckEntity check = SerializeHandler.DeserializeFile <CheckEntity>(json);

            repository.SaveCheck(check);
        }
Example #2
0
        private static void FilesProcessor(string fullPath, string fileName)
        {
            Logger.Log.Info(String.Format("Processing file in CheckFolder: {0}", fullPath));

            try
            {
                if (Path.GetExtension(fullPath).Equals(".txt"))
                {
                    CheckEntity check = (SerializeHandler.DeserializeFile <CheckEntity>(fullPath));

                    RequestHandler.SendRequest(Configurations.CurrentConfig.HostIp, Configurations.CurrentConfig.HostPort, "/PostCheck", check);

                    File.Move(fullPath, UniqueFilePath(Configurations.CurrentConfig.CompleteFolderPath, fileName));


                    Logger.Log.Info(String.Format("Move file to CompleteFolder: {0}", fullPath));
                }
                else
                {
                    throw new Exception("File format wrong");
                }
            }
            catch (Exception ex)
            {
                if (File.Exists(fullPath))
                {
                    File.Move(fullPath, UniqueFilePath(Configurations.CurrentConfig.GarbageFolderPath, fileName));


                    Logger.Log.Error(String.Format("Move file to GarbageFolder: {0}", fullPath), ex);
                }
                else if (Directory.Exists(fullPath))
                {
                    Directory.Move(fullPath, UniqueFilePath(Configurations.CurrentConfig.GarbageFolderPath, fileName));


                    Logger.Log.Error(String.Format("Move file to GarbageFolder: {0} , ", fullPath), ex);
                }
                else
                {
                    throw new Exception(String.Format("Unexpected location of moving file {0} ", fullPath));
                }
            }
        }