public void HandleXlsFile(ref FileStruct file)
        {
            DateTime       created_At;
            ExcelWorksheet worksheet;
            string         xlsxPath;
            string         xlsPath = file.Path + file.Name;

            xlsPath = GetExcelFile(ref xlsPath);
            if (!File.Exists(xlsPath))
            {
                loaderFile.DeleteFile(ref file);
                logger.WriteLog("Error in getting file. Delete file, file name=" + file.Name, LogLevel.Exceling);
                return;
            }
            created_At = DefineDatetimeZipfile(file.Path + file.Name);
            xlsxPath   = ConvertXlsToXlsx(ref xlsPath);
            worksheet  = GetFirstWorksheetExcel(ref xlsxPath);
            if (worksheet == null)
            {
                logger.WriteLog("Can not get First Worksheet Excel from file", LogLevel.Exceling);
                return;
            }
            SortOutProductCells(ref worksheet, ref created_At);
            Upload upload = new Upload(file.Name, created_At);

            database.upload.AddUpload(ref upload);
            logger.WriteLog("Handle xls file", LogLevel.Exceling);
        }
Beispiel #2
0
        public void DeleteApp(ref string request, ref Socket remoteSocket)
        {
            string hash = Worker.FindParamFromRequest(ref request, "hash", TypeCode.String);

            if (hash == null)
            {
                Worker.JsonAnswer(false, "Can not find hash in this request params.", ref remoteSocket);
                return;
            }
            App app = Database.app.SelectByHash(hash);

            if (app == null)
            {
                Worker.JsonAnswer(false, "Can not find application by this hash.", ref remoteSocket);
                return;
            }
            FileD file = Database.file.SelectById(app.app_id);

            if (file != null)
            {
                LoaderFile.DeleteFile(file);
            }
            Worker.uploader.DeleteDirectory(app.app_hash);
            Worker.JsonAnswer(true, "Build completely deleted.", ref remoteSocket);
        }
        public void UploadBuild(ref string request, ref byte[] buffer, ref int bytes, ref Socket remoteSocket)
        {
            List <FileD> files = LoaderFile.LoadingFiles(ref request, ref buffer, ref bytes, ref count);

            if (files != null)
            {
                if (files.Count == 1)
                {
                    FileD  file     = files[0];
                    string app_hash = Worker.uploader.GenerateHash(8);
                    if (file.file_type == "application")
                    {
                        Directory.CreateDirectory(Worker.uploader.Full_Path_Upload + app_hash);
                        App app = null;
                        switch (file.file_extension)
                        {
                        case "vnd.android.package-archive":
                            app = Worker.uploader.UploadAPK(file, app_hash);
                            break;

                        case "octet-stream":
                            app = Worker.uploader.UploadIpa(file, app_hash);
                            break;

                        default:
                            LoaderFile.DeleteFile(file);
                            Worker.uploader.DeleteDirectory(app_hash);
                            Worker.JsonAnswer(false, "Archive type that uploaded is wrong.", ref remoteSocket);
                            break;
                        }
                        if (app == null)
                        {
                            LoaderFile.DeleteFile(file);
                            Worker.uploader.DeleteDirectory(app_hash);
                            Worker.JsonAnswer(false, "Error of handle upload archive.", ref remoteSocket);
                            return;
                        }
                        int?uid = Worker.FindParamFromRequest(ref request, "uid", TypeCode.Int32);
                        if (uid != null)
                        {
                            if (Database.user.SelectId(uid) != null)
                            {
                                app.user_id = (int)uid;
                            }
                        }
                        else
                        {
                            app.user_id = -1;
                        }
                        Worker.JsonData(app, ref remoteSocket);
                        if (file.file_extension == "vnd.android.package-archive")
                        {
                            app = Worker.uploader.GetAPKSet(Worker.uploader.Full_Path_Upload + app_hash, app);
                        }
                        Database.app.Add(app);
                    }
                }
                else
                {
                    foreach (FileD file in files)
                    {
                        LoaderFile.DeleteFile(file);
                    }
                    Worker.JsonAnswer(false, "Get from request not required count files.", ref remoteSocket);
                }
            }
            else
            {
                Worker.JsonAnswer(false, "Can't get file from request.", ref remoteSocket);
            }
        }